What Happens if More than One Message is Sent to the Bot?

When a user is having a conversation with the bot, the usual flow is where the user sends a message to the bot, and the bot responds to that message with a pre-fed response. Well, this is one basic scenario. But, at times it might happen that a user might send two different messages at the same time, with two different intents. In this case, how will the bot respond? Which message will be considered first and which one later? Let us understand this through this document.

It is quite difficult to predict what would happen because of the multi-threaded nature in which the pipeline works on Haptik.

So, every user message that is sent, is added to a queue where multiple (software) workers pick it up for processing. Here, as we discussed in the above paragraph it might happen that 2 user messages that arrived were picked by two workers at the same time and processed parallelly.

Now, the difference in how the pipeline responds is completely dependent on when a user's message is picked by our pipeline's worker for processing.

Let's look at a few examples to understand how this might work.

SCENARIO 1 (Message-1 is processed by the pipeline before Message-2 was picked):

In this scenario, when Message-1 and Message-2 are sent by the user, the bot calculated Message-1's response first and sent it to the user, even before Message-2's response was calculated.

So ideally, Message-1's response will be sent first and Message-2's response will be sent later.

SCENARIO 2 (Message-1 and Message-2 are processed at the same time)

In this scenario when the user sends Message-1 and Message-2, the response for the user's Message-1 gets processed first, but then before it is sent out, Message-2 gets processed. 

So, in such cases, the Message-1's response will be discarded and Message-2's response will be sent back

SCENARIO 3 (Message-1's message was processed a bit later than Message-2)

In this scenario, when Message-1 and Message-2 are sent by the user, the response for Message-2 gets processed before Message-1 (a rare scenario due to multithreading).

In such cases, Message-1's response will be discarded and only Message-2's response will be sent back to the user.

In cases where Message-1 was replied to but Message-2 was ignored, is a similar race condition to that of Scenario 3 mentioned above. This is where perhaps Message-1 was deemed as the most recent one by the bot, which is why Message-2's response was canceled. Again, this is a rare condition.

Can’t find what you’re looking for? Email us at support@haptik.ai.