I am having a trouble with the bot i am building. I have a custom action which takes from 1 second up to 1 minute, later I noticed that if another user is chatting with the bot, the bot will not execute the custom actions until the long task is completed.
Looking for a solution, I found about Event Brokers, however I am not yet able to use them correctly, in particular the pika broker.
I have two questions, employing event brokers will solve the problem of the tasks being solved synchronous? and how do I use them? I have followed the docs but I think I dont have enough knowledge about message brokers D:
since asyncio was introduced, python can actually be run either synchronously or asynchronously. So I think to answer your question properly, we need to know, if the behaviour of your bot relies on the result of the executed action or not.
You will indeed be able to use a MesageBroker like RabbitMQ inside your action, e,g. to send a message with the execution result. The questions are: do the user have to wait for it? Is your story relying on the result? Should your bot be capable of changing its behaviour as soon as the execution finished?
Many things are possible - it would help if you could tell us more about the use-case!
The user needs to wait for the action to get a response. We use of the actions to answer the chitchat of the user, using another chatbot deployed in a Flask application. Also we are trying to answer “almost any” question of the user, searching in the web. This last task is the one that may take up to a couple of minutes.