Tell me, please, how often do they make an answer for the interlocutor?
That is, two users are rewritten, as in vk.com, for example. How should the script know that the second user sent the message?
As I understand it, just set a timer so that after a while he sends a request whether the second user responded or not.
Perhaps there are other options for getting an answer?