My bot keep remembering previous filled slots even though i mention active_loop as null

Can some one help me to fix this.


> - rule: activate document search form
>     steps:
>       - intent: lookingfordocuments   # intent that triggers form activation
>       - action: document_form      # run the form
>       - active_loop: document_form # this form is active
>   - rule: submit form
>     condition:
>     - active_loop: document_form   # this form must be active
>     steps:
>       - action: document_form      # run the form
>       - active_loop: null            # the form is no longer active because it has been filled
>       - action: action_submit
>       - intent: deny
>       - action: utter_welcome

class ValidateDocumentSearchForm(Action): def name(self) → Text: return “document_form”

def run(
        self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict
) -> List[EventType]:
    required_slots = ["userquery", "segment"]

    for slot_name in required_slots:
        if tracker.slots.get(slot_name) is None:
            # The slot is not filled yet. Request the user to fill this slot next.
            return [SlotSet("requested_slot", slot_name)]

    # All slots are filled.
    return [SlotSet("requested_slot", None)]

class ActionSubmit(Action):

def name(self) -> Text:
    return "action_submit"

def run(
        tracker: Tracker,
        domain: "DomainDict",
) -> List[Dict[Text, Any]]:

    query = tracker.get_slot("userquery")
    scope = tracker.get_slot("segment")
    ####Document Search/Lookup logic ####
    botsearchresponse = "some response i am sending here"
    buttons_help = [
            {"payload": "/affirm", "title": "Yes"},
            {"payload": "/deny", "title": "No"},
    dispatcher.utter_message(text ="Is there anything else I can help you?", buttons=buttons_help)
    return []`Preformatted text`

I have no stories created as i was executing the forms with custom

Best Regards, Ravi

Hi @nik202 could you pleasehelp me. I was unable to figure out a fix for this.

active_loop: null only means the form is deactivated; it does not automatically reset slots. If you want to do that, you need to return slot set events that reset all the slots you want to nullify. e.g. [SlotSet("<whichever_slot>", None),SlotSet("<whichever_other_slot>", None) ] or for resetting all slots [AllSlotsReset() ]

1 Like

Hi @mloubser Thanks for your response…

I am sorry, i have done this already and missed to close the issue. Thanks again…

Here is what i did:

class ActionResetAllSlots(Action):

    def name(self):

        return "action_reset_all_slots"

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

        print("resetting slots...!")

        return [AllSlotsReset()]

Best Regards, Ravi