Asking for a slot filling after submit method

Hello All,

I have to call an API, after getting information from a user in a form, I call the following request in my submit() method.

{

booking_code”: “8568”,

booking_otp”: “5713”,

user_id”: “5ec4ecacb9a6b700114603ec”,

no_of_people”: “2” //Optional }

I should call with 1st three inputs (booking_code, booking_otp, and user_id). in response to the API I get a parameter whether I should ask for no_of_people or not.

now once I am already in submit method how can i ask for no_of_people?

@MuraliChandran14, @MingGuangShao @iszainab could you please help?

@omkarcpatil. To my understanding you want to follow up API call. Based on the parameters condition are satisfied i.e getting a response from the API you are calling first. Am I correct?.

First ill take booking_code and otp from user, once i get proper codes, ill call API with following request

{

booking_code ”: “8568”,

booking_otp ”: “5713”,

user_id ”: “5ec4ecacb9a6b700114603ec”, }

now in response of API if i got to know that for this particular booking is for more than 1 person then i have to ask for “no_of_peopl”,

let’s say user said 2 after getting that I will call the API again with following request

{

booking_code ”: “8568”,

booking_otp ”: “5713”,

user_id ”: “5ec4ecacb9a6b700114603ec”,

no_of_people ”: “2” }

You can write a FollowupAction to call another form or action method, If your condition satisfied. No need to declare the follow up form on the stories.md it will automatically picked up by Rasa. Just declare in the domain.yml and below is example code you can modify based on your satisfaction.

class OriginalForm(FormAction):

    def name(self) -> Text:

        """Unique identifier of the form"""

        return "action_form_ask_name"

    @staticmethod

    def required_slots(tracker: Tracker) -> List[Text]:

        """A list of required slots that the form has to fill"""

        return ["name", "email"]

    def slot_mappings(self) -> Dict[Text, Any]:

        return {"name": [self.from_text()],

                "email": self.from_text()}

    def submit(self,

               dispatcher: CollectingDispatcher,

               tracker: Tracker,

               domain: Dict[Text, Any]

               ) -> List[Dict]:

        name = tracker.get_slot('name')

        email = tracker.get_slot('email')

        if name is not None:

            return [FollowupAction("action_form_follow")]

        else:

            dispatcher.utter_message(text=name)

            dispatcher.utter_message(text=email)

            return[]

class FollowForm(FormAction):

    def name(self) -> Text:

        """Unique identifier of the form"""

        return "action_form_follow"

    @staticmethod

    def required_slots(tracker: Tracker) -> List[Text]:

        """A list of required slots that the form has to fill"""

        return ["number"]

    def slot_mappings(self) -> Dict[Text, Any]:

        return {"number": [self.from_text()]}

    def submit(self,

               dispatcher: CollectingDispatcher,

               tracker: Tracker,

               domain: Dict[Text, Any]

               ) -> List[Dict]:

        name = tracker.get_slot('name')
        email = tracker.get_slot('email')
        number = tracker.get_slot('number')

        #sample print
        dispatcher.utter_message(text=name)
        dispatcher.utter_message(text=email)
        dispatcher.utter_message(text=number)

        return []
1 Like

thanks for the work around