Search code examples
phpartificial-intelligencechatbot

How to recognize and handle multiple requests with a single response


This must be a common issue, but I can't find any sources discussing it. There are a lot on the opposite (sending multiple responses to single request).

There's a common human-to-human chat style where personA quickly sends a second message to add to or correct their first message. That is frequently attempted to be used with a chatbot too, for example:

Bot: Where should we deliver the pizza?
User: 123 main street sprnigfelid
User: springfield
Bot: (response to input #1 )
Bot: (response to input #2 )

Now the problem is if the bot is smart enough to recognize misspellings or open enough to accept them from the first input. The conversation would play out like this:

User: 123 main street sprnigfeld
User: springfield
Bot: OK, 123 Main St., Springfield. What state is that in?
Bot: Got it, I will deliver to 123 Main St., Springfield, Springfield. Is that location correct?

There are so many other situations and ways the bot can mistake these multiple rapid inputs and the double responses leave user's wondering what went wrong and confused about where in the conversation they stand.

So has anyone attempted handling of this?

I'm seeking general guidance for an approach, but in case someone has a specific answer, I'm using a PHP Proxy between the User and a Lex bot. I use this Proxy to validate and parse incoming messages before passing them to Lex. I also store session information. One thing I've tried was storing an input_count #, to try to detect if a new input came in before sending the first response.

However, it seems that PHP might be queuing the second input until the first is finished, so there is never a change to my input_count #. So even when the user sends many quick inputs, my bot responds to each one.


Solution

  • Current systems for chatbot development do not have mechanisms (or at least explicit mechanisms) to handle these kinds of situations (correct me if I am wrong). It is usually rule based Q/A. Also agree that dealying the input to the chatbot is not a good general solution. What you could do though is to create some wrapper that would check for this scenario. It could work as follows:

    Bot: Where should we deliver the pizza?  
    User: 123 main street sprnigfelid (you send first input to chatbot) 
    User: springfield (you send second input to chatbot, you make a note that two inputs were sent before first answer) 
    Bot: (response to input #1 ) (you receive answer, but you know there was a second input, you wait for second answer) 
    Bot: (response to input #2 ) (you compare the answers from the chatbot - are they the same?)
    

    The tricky bit is comparing the answers if they are "the same" - if you know the chatbot is responding with the address you could compare the address. You could also detect if the user is fixing a typo right away by comparing the two input messages - if that is the case you could try skipping the second input to the bot altogether and using the context of the conversation from the first answer for continuing the conversation (this is possible with most of the chatbot toolkits).

    In general, I think this is not the main issue one usually has when users are communicating with chatbots. In this particular example the chatbot gives two answers but I would say the user got it right and is not confused - I think this is the main goal of the chatbot.