Message before action appears after

Hi all, I have a custom action that takes some time. I want to tell the user to expect to wait so I create an utterance (utter_wait) and then execute the action. However, in rasa x, the utterance action doesn’t execute until after the custom action has completed, which defeats the point. Is there any way to force it to do the first action before the second?

FYI here’s my story:

stories:
- story: analyze my story
  steps:
  - intent: greet
  - action: utter_greet
  - intent: checkanalysis
  - action: utter_articleanalysis
  - intent: help
  - action: utter_gdochelp
  - intent: gdriveurl
  - action: utter_read_aa
  - action: action_check_analysis
  - action: utter_anything_else
2 Likes

Could you break these down into two actions?

The first action_wait would dispatch a message asking the user to wait (something like dispatcher.utter_message(template="utter_wait") and then return a followup action to run using FollowupAction(name="action_that_takes_a_long_time_to_perform") from the rasa_sdk.events.

By the way, why does this action take such a long time to run?

Hi Shorouq, Thanks for the suggestion, I’ll try that. The action reviews a document for spelling and grammar mistakes as well as checking for various components in the document. It just takes about 30 seconds to run. But that’s a long time to stare a bot not talking to you!

1 Like

That makes sense! Good luck and let me know if it worked.

No, sadly that didn’t work. I tried both returning it as a followup action and as just a second action in the story. It still doesn’t seem to output anything until it hits an action_listen. Any other ideas?

Why not just define a response asking the user to wait, and call it before your custom action?

1 Like

I have that, it doesn’t appear until action_listen is called. So it doesn’t come up until after the action has run. The only way I can get it to appear at this point is to say “This will take a long time, continue” and then have two buttons. once the listen action occurs the message appears witing for the affirm intent, the message displays.

That is weird. If you posted your stories and domain files I might be able to help you more. Right now I’m having trouble following. What do you mean by “it doesn’t appear until action_listen is called?”

1 Like

Do you mean that both two actions only run together at the same time, and not one before the other (as they should)? Does that also happen if you try it in Rasa shell?

Sorry its taken me some time to get back, I’ve been working on getting this set up so other people could test it. So I created a repo with a bot that will exemplify the problem. Its very simple and the goal is to make an utterance and then execute an action with a 10 second sleep statement which then sends a utterrance as a result. Its here rasa action delay github. This will not work with either Rasa X or Rasa shell. No response is displayed until the action is complete. I then tried to create another intermediate action that simply issues its own utterance before the last action is executed. I have found with rasa shell, if I send an utterance (“please wait”) and then execute an intermediate action (that simply sends an utter_message) before the action that causes the delay, the intermediate action causes the first utterance to appear. The utter_message from the intermediate action, and the ultimate action’s result will not appear until the last action completes. In Rasa X, however, this intermediate action has no effect and nothing appears until the ultimate action has finished.

I know this is a little confusing so I’ve set up the github repo so you can try it yourself, but in a nut shell:

Rasa Shell

  • intent: greet
  • intent: utter_greet
  • intent: show_problem
  • action: utter_problem - says “please wait” does not display
  • action: action_delay - when complete the above utterance and the actions result displays simultaneously

Rasa Shell with intermediate action

  • intent: greet
  • action: utter_greet
  • intent: show_problem
  • action: utter_problem - This says “please wait” it does not display
  • action: action_utter - This issues an utter_message and causes the above utterance to display
  • action: action_delay - this is the delay action, after it finishes the result of this action and the one above now display

Rasa X - both examples work the same and nothing displays until the final action completes

I suspect I should file a bug report, but thought I’d see if anyone has an idea here first.