Story generation for "Please wait"

Hi,

Rasa core API are POST api’s. They give response only when executed.

Now, when user is asking some question and i need to do some heavy task for the user’s query after intent classification,i need to display “Please wait” to the end user.

How can we achieve this? Do we need to handle this at the UI end?

Ex:- Bot: HI, How can I help you? User:Where is this order 3423423? Bot: Let me check –after this step there is a time gap as i need to do heavy form actions,calling various API’s etc etc. Bot: Your order has been shipped already

How do i handled this?

@aniket i would suggest just sending a message before you execute this action

1 Like

I did that but the we get that message as well as the action response message together when api call is made. because i am making rasa api call from UI i get all the message at the same time.

I guess i need to handle it from UI’s end.

May i know in which function should i try sending this message so that i can appear in UI before the actions start executing?

Just another action before the action that does the heavy work. Just add that to your stories or include a FollowupAction-event in the first action.

I am using formaction to fill the slot and do heavy work.

This is my story

  • get_order_data

    • order_info_form

      • form{“name”: “order_info_form”}

      • form{“name”: null}

      • utter_ask_did_that_help

  • affirm

    • utter_gratitude

    • utter_anything_else

do i need to add custom action?if yes, where should i add in story?

@aniket is it the form action that performs the long running action? Could you show me where in the code you send the message to the user at the moment?

def submit(

        self,

        dispatcher: CollectingDispatcher,

        tracker: Tracker,

        domain: Dict[Text, Any],

    ) -> List[Dict]:

        """Define what the form has to do

            after all required slots are filled"""

        dispatcher.utter_message(template='utter_bot_checking')

        sender_id = tracker.sender_id

        userObj = UserProfile(sender_id)

        order_num = tracker.get_slot('ordernum')

        intent = str(tracker.latest_message['intent'].get('name'))

        obj = OrderSearch()

        obj.full_username = userObj.full_username

        response = obj.getOrderData(order_num)

        if response.status_code == 200 and len(response.json())>0 and order_purge_intent == True:

            dispatcher.utter_message(template= 'utter_order_purge')

            return []

        elif order_purge_intent == True:

            response  = obj.getPurgedDataInfo(order_num)

            dispatcher.utter_message(response['data'])

        else:

            dispatcher.utter_message("")

        

        return []

i am sending message when all the slots are filled. after that i am calling various api’s in my separate classes

I would suggest sending the message from the form, but then performing the logn running actions in a separate action

Hi @akelad ,

I’m trying to implement that scenario but even if I’ve broken the “please wait” message from the long running action I still receive the information all together on the web UI

This is the submit Form method:

def submit(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[Dict]:

        # Retrieve slot values
        udc_number = tracker.get_slot('udc_number')
        informative_system = tracker.get_slot('informative_system')

        dispatcher.utter_message(template="utter_please_wait")

        # I've tried to use this but it's the same
        #tracker.trigger_followup_action('action_call_custom_api')

        # Then I've tried to return a FollowupAction
        return [SlotSet("udc_number", udc_number),
                SlotSet("informative_system", informative_system),
                FollowupAction('action_call_custom_api')]

What should I do to make it work?

Thanks

@GabrieleRomeo I would suggest putting this action in your story, after the form completes. Using FollowUpActions isn’t recommended

Hi @akelad Thanks for you suggestion. I’ll try it

@GabrieleRomeo. Did u solve this?

Hi you all!

I’ve been having the same issue. I’m using “dispatcher.utter_message(response=“utter_wait_message”)” in a separeted action. But in the UI, I only get the messages all together (after making the request to an API)… Could someone please help me out?