How does using custom action to ask for the next slot works in forms

Consider a form with two slots, username and place.

Bot: What is your username?
User: my username is jane_doe_123

Rasa form requests (utter_ask_username) and sets the slot username as jane_doe_123 Now for requesting the age, rather than just saying where are you now?, you want the bot to make the request like, Where are you now Jane Doe?

Here from the username extracted you need to find the name of the user and make a utter request with the name. For such cases you can use custom action to ask for next slot. In your custom impl code, you can send the value extracted for slot username send a GET request to your server and get the user’s name and then display the message with that name.

This is just a sample case where you’d want to use a custom action to ask for form slots. Hope you understood.

okay but what i was doing was where the bot asks in the form not from “utter_ask_slot name” but from 'action_ask_slot name"…here is the logic user: book an appointment for me… bot : select the department you want (here instade of utter_ask_slotname" i used “action_ask_slot name” becouse i need to display list of departments in a button that is fetched from database)… user: selects the department… bot: here are the available doctor found this department select one from the list(here also i used “action_ask_slot name” that is fetched from database by taking the user selected department slot value")… here is the problem i can not fetch the second list of doctors from the database becouse the query didnt work and why is that it did not get the department slot and i dont know why

Can you check in logs whether the slot department was set properly when the user selected one? If not please check you slot mapping and the entities that was extracted.


Can you help me how are you using action_ask_slotName as for me when i try to do so the actions is not executed. i am not sure why

1 Like

@tahakapadia …1.make sure your rasa version is more than 2…and second make sure your action is written under action in domain.yml file

1 Like

I have the same problem. Did you solve it @tahakapadia?

class ActionAskUsername(Action):
    def name(self):
        return 'action_ask_username'
    def run(self, dispatcher, tracker, domain):
        dispatcher.utter_message("It works!")
        return []

Yet the action doesn’t even run. If I use an utterance utter_ask_username instead, it works.

have you specified action_ask_username in domain file? bcoz i had the same issue and when i added action it worked

1 Like

Ah yes, that was my mistake. I wanted to edit my reply but I forgot by the time training ended lol.

Thanks for reminding me.