Well, I tried returning self._deactivate() in my custom validation, and it deactivate but there is a problem: if there is a required field not filled yet in the form it will concatenate the self._deactivate() + set required_slot action to the next required field. So I don’t like this approach since, lets imagine this scenario:
- I have a FormAction with 3 required fields:
- TICKET_TYPE (using slot_mapping = self.from_text())
- TICKET_DETAILS (using slot_mapping = self.from_text())
- TICKET_QUANTITY (using slot_mapping = self.from_text())
So, when I enter in this Form it will ask for TICKET_TYPE, which expect any text from the user.
Ok then, now let’s suppose, when the bot asks me about TICKET_DETAILS (utter_ask_TICKET_DETAILS) I want to cancel the form with “/cancel”. If I cancel the form using the command “/cancel” (catching this string in the custom validation method) and then return self._deactivate(), it appears to concatenate the form deactivation command + setting a required slot, like:
[‘Form(None)’, ‘SlotSet(key: requested_slot, value: None)’, ‘SlotSet(key: requested_slot, value: TICKET_DETAILS)’]
When it should be:
[‘Form(None)’, ‘SlotSet(key: requested_slot, value: None)’]
So, what is the problem with canceling from inside the custom validation method? Basically, when it appends the “SlotSet(key: requested_slot, value: TICKET_DETAILS)”, it will call utter_ask_TICKET_DETAILS, which doesn’t make any sense in this context since the form is already canceled (and yet the bot will ask for the new field).
So the problem with this approach is the bot uttering ‘utter_ask_TICKET_DETAILS’ even after deactivating the form, which doesn’t make sense since the user is already out of the form (now deactivated).
This scenario and behavior don’t occur, however, when typing “/restart” in the user input.