Reset slots before deactivating in validate() function

Hello everyone,

I’ve managed to implement the deactivation of the form when the user wants to inside the validate function() thanks to this post. However, the slots filled before cancelling the form keep their values. Is there a way I can reset all slots before returning self.deactivate ? When I call the form again, the bot continues from where we stopped, I don’t want that.

Thanks.

Hi @forwitai,

how about this solution by resetting the slots via event?

Kind regards
Julian

Hi @JulianGerhard, thank you for the quick reply ! I’m actually still using Rasa 1, just to be sure I’m following, I need to use this method ? But how can I integrate it in the code you provided earlier ?

Thanks.

I’ve tried using it right before self.deactivate() but I got an error saying ‘Tracker’ object has no attribute ‘_reset_slots’ ! I also want to mention that I am not able to deactivate the form using stories as in the documentation, only your method worked, so I can’t reset slots via stories either.

Thanks.

@koaning can you help please ?

Hi @forwitai,

why dont you create a list of SlotSet events with setting all their values to None and append the deactivate event at the end - then return the list?

Kind regards
Julian

Hi @JulianGerhard,

you mean something like

return [SlotSet(slot, None) for slot, value in slot_values.items()]

Where should I put the self.deactivate() exactly ?

Thank you for your time.

self.deactivate() is similar as [Form(None), SlotSet(REQUESTED_SLOT, None)], So you can do it all together by return [SlotSet(slot, None), Form(None), SlotSet(REQUESTED_SLOT, None)]