How can I quit from a Active Form

Okay, but I will need to do some validation, no?

Because if I haven’t canceled it should request the next slot and not deactivate the form…

I thought in the “run” function, check if there is the deactivate form command, and if it exists, do not concatenate the command to request the next slot command, like (check TODO on what I was planning to do):

def run(self, dispatcher, tracker, domain):

    events = self._activate_if_required(tracker)
    events.extend(self._validate_if_required(dispatcher, tracker, domain))

    temp_tracker = tracker.copy()
    for e in events:
        if e['event'] == 'slot':
            temp_tracker.slots[e["name"]] = e["value"]

    next_slot_events = self.request_next_slot(dispatcher, temp_tracker,
                                              domain)
    #TODO: Develop an condition (if) that if the deactivate command combination exists ([‘Form(None)’, ‘SlotSet(key: requested_slot, value: None)’]) do not extend the events list with events.extend(next_slot_events)
    if next_slot_events is not None:
        events.extend(next_slot_events)
    else:
        events.extend(self.submit(dispatcher, temp_tracker, domain))
        events.extend(self._deactivate())

    return events

I’m not, however, very familiar with Python yet, and I do not know what would be the ideal and more performative way of doing this condition. It would be of great help if you could help me with the writing of this condition in the best practices.

Also, is there any way to dispatch an event? Like, from inside the custom validation method, dispatch some event which is immediately and synchronously executed and only after that return the events of the custom validation method?