How do chatbots work?

With the advent of chatbots; customer support, marketing, and lead generations of the world have reformed. Paying a credit card bill, claiming insurance, or booking a table at your favorite restaurant has never been this easy! Chatbots have revolutionized communication!

In case you don’t know what is conversational AI-based chatbots, where and how it is used in the business then, do give this article a read.

A lot of magic happens within a chatbot! From the user inputs to a chatbot to the response received, it is an exciting journey for the data. The operation is similar to the “request and response” process of a Web application. Data is structured in Web applications whereas unstructured in Chatbot.

Well, What is our goal here? To have a machine understand what the human speaks and respond accordingly in human-understandable language. We certainly have come a long way from the assembly language 😉 We are looking at an AI case where computers meet human intelligence.

In 2001 Richard Wallace developed AIML(Artificial Intelligence Markup Language). This used the ‘Rule-based approach’, which was mostly powered by a pattern matching mechanism. The bot would search for a pattern and respond to anything related to the pattern. Though this approach was followed for many years, it started to fail when more complex questions were posed.

Simple AIML example of Pattern matching
Simple AIML example of Pattern matching

Enter NLP!

Natural Language Processing is a branch of AI that involves programming computers to process data, breaks down natural language into smaller elements in order to understand the relationships between those elements and how they work together. Common tasks include parsing, speech recognition, part-of-speech tagging, and information extraction. NLP focuses largely on converting text or audio(unstructured data) to structured data.

To know more about NLP, hit this article.

Let us take this simple example,

The “Hello World” of chatbots is the Restaurant bot! Yup, you read it right!

The restaurant bot gives information on nearby restaurants with locations while matching the tastes, cuisine, and popularity and also helps us book a table. There is a three message exchange between the user and the bot. Let us break it down,

NLU(Natural Language Understanding), a subset of NLP, plays a critical role in the classification of the inputs to the bot.

NLU adopts AI algorithms to identify attributes of language such as sentiment, semantics, context, and intent. With NLU, computer applications can recognize the many variations in which humans say the same things. Example, “i want to have Indian food”, “tell me the best place to eat indian” or “I am craving for some indian food”

Taking a deeper dive,

Key Components,

  1. User utterance — Input from the user
  2. Channels — Various mediums are used for hosting the chatbot. Popular ones today are Facebook Messenger, WhatsApp, Slack, Twilio, etc. Chat can be hosted on any website.
  3. NLP Tool — Though chatbot can be built from scratch using ML, most of the work is done by some brilliant bot frameworks like DialogFlow, Rasa, LUIS, etc. which facilitate the capabilities of NLU and Dialog Management. Further, you can customize models based on the chatbot use case.

NLU Engine does two operations,

  • Intent Classification: The user’s input is identified and based on the meaning, it is related to one of the intents that the chatbot supports. For example, “Show me my credit card balance”, and” How much money do I owe on my credit card” will be recognized as the same intent, i.e credit card balance or credit card dues.
  • Entity Extraction: The key information is extracted from the user query. In the example above, “credit card” will be extracted as an entity(account type).

Dialogue Management determines the context of the conversation. It is responsible for the state and the flow of the dialogue between the user and the chatbot. It handles the twist and turns that occur in a conversation.

  • Policy Learning: The chatbot uses policies to assess and choose the next action for the conversation. It provides the response that has the highest confidence level. In the case of FAQs or rule-based chatbots, the work of a dialogue manager is pretty straightforward. Based on a set rules policy, the response is floated to the user. But, if it is a conversation, the machine learning policies come to play. For instance, if the user says “Provide my credit card balance” and then changes it to “No, I need my savings account balance”, the bot should be clever to handle the state, pick the right entity/intent and provide the response keeping the context intact. The bot learns from its user interactions and follows conversational flow based on past data.
  • Feedback Mechanism: The chatbot takes the feedback from the users periodically to assess conversational efficiency and user satisfaction levels with the bot’s response. This augments the bot to learn and upgrade itself for future conversations.

This is the place where machine learning models thrive and based on the languages, scope, spectrum of users, etc. the decision of choosing a pre-trained model or making a model from scratch has to be made. The chatbot should be intelligent enough to handle single-turn conversations, multi-turn conversations, out-of-context questions, chit-chat, multiple intents, small talk, and also fallback gracefully.

4. Database or API call — External components offer chatbots solution APIs and other sources for retrieving answers. Based on the entity/intent classified, the user response is received.

5. Bot utterance — Response sent to the user by the bot either by text or voice.

The power of chatbots is enthralling. A chatbot is considered an alternative human being with human-like tendencies to get it wrong or be boring at times but it’s our job to make a near-perfect replica.

Doesn’t that sound exciting?!!!!!!!!!!

If you like what we do and want to know more about our community 👥 then please consider sharing, following, and joining it. It is completely FREE.

Also, don’t forget to show your love ❤️ by clapping 👏 for this article and let us know your views 💬 in the comment.

Join here: https://blogs.colearninglounge.com/join-us