Make your AI Bot experience closer to a user friendly NLP experience - Simulate a real conversation - Understand context, Intent, Follow Up intents - using Dialog Flow (API.AI)

I have seen many forums where people are not able to understand concepts and hence not able to use the nice features on the AI Platforms e.g. the context flow in API.AI.

This blog will make you understand concepts in easy terms and how to use enhanced context features in framing a NLP flow via API.AI (dialog flow).

Intent : Whenever you go to talk to someone, you have something in mind to achieve by end of the conversation, this is called intent.
Context : When you are in conversation, you expect the person to reply to your question, not to reply or start something totally different and to complete the conversation. A series of messages exchanged to close a conversation end to end.

I will explain with a simple example of an AI bot.

--------------------------------------------------------------------------------------------------------------------------
AI Bot : "Hey , How are you? May I know your phone number"
--------------------------------------------------------------------------------------------------------------------------
Here the Intent is :  "GetPhoneNumber" as you expect to get the phone number with this sentence.

To understand the contexts and continue talk, we will simulate real user conversation (a real conversation simulation is needed to make a successful NLP).

For this question the expected reply in a real conversation can be :
1. User answers as Expected/Correctly (user tells the phone number).
2. User does not want to answer or answers in negative ( user does not want to tell).
3. User will answer later (user will tell phone number later).
4. User wants to know more about your question (user wants to know, why he should share his number).
5. User want to stop the topic of discussion and requests you to stop or cancel (user want to end or stop this topic).
6. User replies something not understandable or not expected, and does not fall in any of the above (user answers something totally out of context).
** Note there can be other possibilities, but these are highly probable in a usual NLP.

As you expect (see definition of intent aboveall these possibilities will fall into intents and are called as followup intents e.g. GetPhoneNumberCustomerAnswersWithThePhonenumber, GetPhoneNumberCustomerDoesNotWantToTell, GetPhoneNumberCustomerNeedsMoreInfo, GetPhoneNumberCustomerRepliedSomethingWeird etc.

By now you know what are intents and follow up intents.
Now guess what is context?
Despite of any answer your conversation is still about phone number, irrespective of the answer provided until the conversation is stopped (positively or negatively).
So the "context" is all this time until "this" conversation is stopped.
So all these intents and follow up intents need to maintain a common context chain, by passing inputs to next intent and using it in next intent.

In Google dialog flow(API.AI), you can manage the context of conversation for the above cases with the mapping of table as below. You can further continue and choose the next action based on the previous context similarly.

Use cases
Follow Up Intent
User answers as Expected/Correctly (user tells the phone number)
Yes or Custom ( based on need)
User does not want to answer or answers in negative (user does not want to tell).
No
User will answer later (user will tell phone number later).
Later
User wants to know more about your question (user wants to know, why he should share his number).
More
User want to stop the topic of discussion and requests you to stop or cancel (user want to end or stop this topic).
Cancel
User replies something not understandable or not expected, and does not fall in any of the above (user answers something totally out of context).
Fallback

Next, there is a Tip to use these contexts.
I will explain that in next blog.


















Comments

  1. Very interesting, Himant. I've been looking at conversation modelling in terms of how successive turns are related, even when the response is not the expected one. Follow-up intents look like a good way to handle this. Looking forward to your next article.

    ReplyDelete
    Replies
    1. Thanks. Do subscribe and share. Hope i will continue to post and make readers happy . Best of luck.

      Delete

Post a Comment