Filling form's slots using custom actions

Hello,

How do I fill the slots using custom actions? For example:

I have a form where I have defined the slots in function such as:

@staticmethod
    def required_slots(tracker: Tracker) -> List[Text]:
            return ["name","cuisine","time"]

I want to define the utter_ask_cuisine as a custom action because the value will be shown as a button and be fetched from the backend (which is dynamic in nature).

class ActionCuisine(Action):

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

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
        cuisine_data = grabCuisine()
        buttons = []
        for data in cuisine_data:
            buttons.append({"title": data, "payload": "/cuisine"})
        slot_name = tracker.get_slot('name')
        dispatcher.utter_message(
            text="Please choose your liking", buttons=buttons)
        return []

Is it possible to fill the slot value by calling a custom action that fetches the values from the backend? If I am defining the utter_ask_cusine template as part of the response in the domain.yml file, it wont be dynamic but will have fixed button values.

I am getting the following error:

UserWarning: Utterance ‘utter_ask_cuisine’ is listed as an action in the domain file, but there is no matching utterance template.

Any reference would be really helpful :slight_smile:

Thanks.

Hey @_adityaK you can just add the following code to your return[]

 return [SlotSet('slot_name', 'slot_value')] 

Hope it helps :slightly_smiling_face:

Hey @jusce17, thanks for your reply. :slight_smile:

But I will take a step back. To set the slot_value for cuisine, I need the input from the user. How can I call the ActionCuisine when the bot comes to the slot cuisine in the function required_slots.

Can we define utter_ask_cusine as a custom action the way I have done it above?

Apologies if I am not clear with my question :frowning:

I was able to achieve this by using request_next_slot(). Thanks @jusce17 for your input. It was helpful :slight_smile: