I’ve developed a chatbot for Messenger platform that uses sender actions (typing and seen). I would like these actions to look more natural by adding a delay between the seen and typing indication.
For instance, user sends a message and bot shows “seen” action for 1 sec. Then, bot shows “typing” action for 2 sec until a response is sent. I’ve tried this with time.sleep() method in python, but I believe it isn’t a good practice.
Has anyone tried this? Any help or suggestion will be appreciated.
Ideally this sounds more like something you should be doing on the frontend, rather than forcing the bot to delay its response.
If you’re developing your own frontend in, say, Javascript, its as easy as adding in a sleep() statement between receiving and displaying the message.
If instead you’re developing for something like Slack or Facebook, their respective bot APIs should ideally have bools for “is_typing” or something along those lines, which you can set and delay before responding.
Did anyone find a good solution for this? I have a similar issue where I’d like to delay the bot’s next utterance and give the user ~10 seconds to respond to the last message before moving forward.
Python sleep() will pause for an hour, day or whatever if given the proper value. It does not allow other processes take place (in same script) however. A better way is to use an event which will create an event on timeout.