I was wondering if it’s possible to utter something while a request is processing. For example, if the user asks a question that goes to a custom action, is it possible to utter “Give me a second to search that for you…”, perform the HTTP request and when the results are obtained, utter the result (all within the same custom action?).
I tried to use dispatcher.utter_message twice but it only prints after everything is done.
You can do this in the stories. Something like this:
* Intent
- utter_wait
- action_Your_customAction
Define utter_wait in your templates in domail.yml as Give me a second to search that for you….
When the intent is identified, it will utter_wait and then trigger your custom action.
Thank you a lot for the suggestion! Although that solves part of the problem, it doesn’t really solve sending multiple wait messages before the final result is delivered, however I’ll accept the answer if no other alternative exists.
is it necessary to wait for the HTTP request to return in the custom action? If not I would
suggest to enter the custom action, utter via dispatcher, start the request either in a new thread or with asyncio and return the custom action.
this is why I asked for the necessity to wait for the request. It could have been the case that it is a fire-and-forget process and then you could have done it my way. Unfortunately, Python handles things synchronously - so no, you can’t simply utter something this way.