Utter message while validating

I’m facing some issues while validating some data. I’m building a “market” in which you ask for a product and a quantity with it’s units ( kg for example). In the validation I check an API so i can ensure that the given units goes with the product, so nobody could ask for 2 liters of fish, which makes no sense.

The problem here is that while fetching the data from the API I want to utter a message saying something like: Searching… But, if I try dispatcher.utter_message it waits til the validation is over to utter the message. Is there any way to solve this? Because the API calls are too slow.

Thx in advance.

@palagonKevo are you able to validate and fetch the data from API?

Yes, this is the expected behavior.

All events happen after the whole custom action finishes running.

The following code will do nothing for 5 seconds and utter A then B right after it:


What you could do is implement the required_slots() method, and if it’s the turn of that slot, you can dispatch the message before return, and the validate() method will take place after that.

The problem here is that I only need to dispatch the message if a condition is met, so, it makes no sense to ask the bot to say a phrase at the beginning of the validation, it must be while validating, at least to let the user know that the chatbot is thinking.

If that’s the case then okay. I don’t know what you’re doing so I can’t guess what makes sense or not in your case.

But can’t you check for that condition in the required_slots() method?

Because again, dispatching before the end of the function is not an option.

Was your issue solved?

If yes, please share the solution.

No solution found yet. Idk how to solve it, I just avoided it by improving the speed of the data extraction of the db.

1 Like