I think I have found a way.
- I have defined a slot:
deactivate_form: type: categorical values: - flight_departure_form - flight_arrival_form #influence_conversation: true <- this does not yet work in 2.0rc3
- I have created custom actions for forms asking for slots (rasa will ask for them even if a form “decativation” is requested):
class AskForSlotActionFlightInfo(Action): def name(self) -> Text: return "action_ask_sl_frm_flight_info_abstract" def run( self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict ) -> List[EventType]: print(" Tracker slots:", {k:v for k,v in tracker.slots.items() if v is not None}) ## is there a deactivated form? deactivate = tracker.get_slot("deactivate_form") if deactivate: form = self.remove_suffix(deactivate, "_form") if form in self.name(): return [] dispatcher.utter_message(...) return [] class AskForSlotActionDepartureAirline(AskForSlotActionFlightInfo): def name(self) -> Text: return "action_ask_sl_frm_flight_departure_info_airline" class AskForSlotActionDepartureCity(AskForSlotActionFlightInfo): def name(self) -> Text: return "action_ask_sl_frm_flight_departure_info_city" class AskForSlotActionDepartureTime(AskForSlotActionFlightInfo): def name(self) -> Text: return "action_ask_sl_frm_flight_departure_info_time"
- And finally, I created a rule:
- rule: Deactivate form condition: - active_loop: flight_departure_form - slot_was_set: - deactivate_form: flight_departure_form steps: - action: flight_departure_form - active_loop: null #- action: utter_deactivating_form - action: action_reset_all_slots_flight_departure_form
It seems to work. Is there a better solution?