Is there some way we can get the name of active form or active loop?

Is it possible to get the name of the active loop or active form in custom asction?

If there is an active loop, and you’re inside a FormValidationAction:

'_'.join('_')[1:]) will return its name.

not inside a FormValidationAction

You can do print(tracker) and get all the information you possibly can about a conversation. If it’s not there, you can’t get it.

And, the tracker has a way for getting the current active loop :slight_smile: Just use tracker.active_loop or tracker['active_loop'].

See the Tracker reference.

Another way to do that is to have a slot for it, which you save when you enter the FormValidationAction and access in the Action, then reset when you finish the form or the action, depending on your needs.

You can also read the data inside the tracker store and find the last active loop for that conversation. I don’t recommend this though.

this didn’t work

What do you get when you do print(tracker)?

I didn’t try printing tracker, I printed tracker.active_loop and it was a huge chunk of data

Yes of course, it’s all the info about the conversation.

Do you not see any relevant information there? Send it here if you want. (when you’re inside an active loop)

I have 4 forms , and each of these forms collect basic details like phone-number, name. And depending upon the form i want to ask prompt (asking for a slot value) in different style . So somehow I need to know which form is active at the moment. storing a value in slot to identify the form is a good a idea, but how do I do that.

My very first prompt depends on the slots that identify the form, so that slot has to be filled before asking form.

I did something like this, But this effects pre-filling

  async def validate(self, dispatcher, tracker, domain):
        slots: Dict[Text, Any] = tracker.slots_to_validate()
        intent = tracker.get_intent_of_latest_message()
        if tracker.get_slot("current_state") != 'room_booking':
            slots['current_state'] = 'room_booking'
            return [SlotSet(slot, value) for slot, value in slots.items()]

        (remaining validation code) 

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

1 Like

Ah, you can have differently named slots for each form and ask for those, then, in their validation, you can return the renamed slot as well as the original one.

return {"name_one": value, "name": value}

active_loop = tracker.active_loop.get(‘name’)

1 Like