concept intent in category chatbot

appears as: intent, intent, intents, intents, n intent
Building Chatbots with Microsoft Bot Framework and Node.js

This is an excerpt from Manning's book Building Chatbots with Microsoft Bot Framework and Node.js.

AI based chatbots, in contrast, use Natural Language Processing (NLP) to understand the meaning of the input message, also known as intent. They can also extract other relevant information like city name, time or any other contextual information that might be needed for handling the request. The process of extracting this contextual information is also called entity recognition. These bots generally use freeform text input, as they are capable of handling the various kinds of user requests. Figure 1.6 shows an example of an AI based bot handling the same pizza order.

Listing  3.1  Adding string matching to our chatbot where we replace the simple echoing back with checking for each intent using string matching and replying based on the intent.
// Listen to messages sent by users server.post("/api/messages", connector.listen()); // Respond with appropriate message var bot = new builder.UniversalBot(connector, function(session){ var get_nutrition = ["what is the fat content in a cheese burger", "what is the fat content in a pizza"]; var get_workout_info = ["how to do a pushup?", "how to do a sit up?"]; var hi = ["hi", "hello", "hey"]; var bye = ["Bye","Goodbye"]; var input_phrase = session.message.text; if (get_nutrition.includes(input_phrase)) { session.send("Okay will get nutrition information"); } else if (get_workout_info.includes(input_phrase)){ session.send("Okay will get workout information"); } else if (hi.includes(input_phrase)){ session.send("hello"); } else if (bye.includes(input_phrase)){ session.send("goodbye"); } else { session.send("Sorry, couldn't understand"); } });

We can see that the score is highest for “Get Workout Info” which is the correct intent category for the query “Help me in doing pushups”. In practical applications, there is also a threshold for the scores. The intent is considered a match only if the score is above the threshold. This is to avoid incorrect classification or recognition of intent. For example, if you consider the query “In the ball”, the highest score would be 0.833 for the intent “Get Nutrition”. But clearly the intent or meaning of the query was not related to nutrition at all. You can avoid such situations by having a minimum threshold for the scores and also not considering commonly used words like “in”, “the” and other such words for calculating the scores. These words are also called as stopwords.

Now, go back to initial list of intents we came up with before and add examples for all of them.

Figure 3.10  Adding examples to an intent