Conversation AI: Chatty Chatbots!

Published on November 2, 2022

“AlphaGo from Google beat the best player in the world.” That is the power of prediction by artificial intelligence (AI) in today’s era which is constantly developing to achieve new milestones. In today’s times leveraging AI is possible in all domains. One of its applications that is currently being widely used is in developing conversational AI (Conv AI). ConvAI uses Natural Language Processing (NLP) to improve human-to-machine conversations by understanding text or speech inputs, identifying the intents, and responding with relevant information. The main components required for ConvAI are machine learning, natural language understanding (NLU), automatic speech recognition, and text-to-speech or speech-to-text conversion.  

Chatbots, virtual assistants, and voice bots leverage ConvAI to create natural human-like conversations to automate workflow. From the healthcare industry to the hotel industry, chatbots are being deployed in almost every domain to accelerate operations. 24/7 availability of chatbots to handle customer queries has revealed a new dimension to customer care that not only engages the customers but also saves human resources for other tasks.  

Approaches for Chatbot Design 

1) Rule-based: A rule-based chatbot has fixed questions and responses and gives users a set menu to select from. These types of chatbots are helpful in performing tasks like booking a table in a restaurant, buying tickets to the cinema, or using online delivery services. One disadvantage of rule-based chatbots is that they depend on user input. For example, in case the customer query does not align with the pre-defined rules, these chatbots are unable to reply appropriately since they cannot recognize the conversation context. 

2)Machine Learning (ML): An AI chatbot can answer the customer’s query by catching the intent behind his/her question and responding appropriately. It leverages NLP technologies that augment the bot’s functionality leading to the identification of several intents and thus enhancing the bot’s capability to answer different questions.    

There are several frameworks available for developing Chatbots, for example, Dialogflow, AzureBots, Rasa, ParlAI etc. Dialogflow is a Google service that runs on Google cloud platform. It is a natural language processing platform that can be used to create chatbots and integrate them into websites. Azure Bot service offers several ways to build and deploy chatbots like Bot Framework SDK, Powerful virtual agents, and Bot Framework Composer. ParlAI is a python-based framework that can be used for training and testing dialogue models and developing visual question answering. Here we will explore Rasa, which is an open-source ML framework for creating chatbots [1]. Chatbots built using Rasa can understand messages, hold conversations, and connect to several messaging services like Telegram, Slack, WhatsApp, Messenger, and Microsoft Teams. Primarily there are two modules that makeup Rasa:  

1. Rasa NLU: It classifies the intent behind the user’s input and extracts the required entities. 

2. Rasa Core: It recognizes the user’s input and generates a response accordingly using various pipelines.  

Way of Working 

Let us understand intent and entity with an example.  

User’s question- “What is the weather like tomorrow?” 

The intent of this question is that the user wants to know the weather and entity is tomorrow. 

 

Rasa has its own model for intent recognition and entity extraction i.e. DIET (Dual Intent Entity Transformer) classifier. Entity extractor like Duckling is used for extracting time, date, phone number, and URL while Spacy is used for extracting names of people, places, and organizations. Components like Tokenizer, Part of Speech Tagger, chunker, etc. are parts of a natural language processing pipeline. 


Rasa Core handles dialogue management which keeps a track of the conversation history which is saved by Rasa Tracker and Rasa Policy chooses the next action accordingly. An action is a function in Rasa that is used to display the required information or perform a task, for example fetching details from a file or saving the conversation. The action executed by Rasa depends upon intents and entities which are trained using ML models. Rasa’s interpreter provides the information of intents and entities based on which the next action is executed.

 

 The Training Data Files in Rasa: 

Let us consider an example of a FAQ (Frequently Asked Questions) chatbot that answers HR-related queries about leaves, insurance, payroll, holidays, and reimbursements. 


The training data for NLU has YAML files: nlu.yml, stories.yml, rules.yml, domain.yml. The nlu.yml file has all the intents and examples for each intent. For example: user can ask about leave application process in different ways. 


 The stories.yml file has sample conversation flow between user and bot. Stories are used to train models that can generalize to unseen conversation paths. For example: if the user asks  a leave-related query then the bot action is to utter the required answer, the sequence of the conversation can be seen in the story below. 


 The rules.yml file describes short pieces of conversations that should always follow the same path. For example: if the user utters goodbye the bot should always reply bye.  
 

The domain.yml file contains all the responses, known as utterances to the intents mentioned in the nlu.yml file. 

With all the data files in place and using bot framework credentials that are required for deploying the chatbot on Microsoft Teams, a sample conversation for a leave query would look like the one below-

In conclusion, the flexibility and the extent of customization is what makes Rasa a great tool to develop chatbots. Rasa chatbots come under the umbrella of contextual assistants as they are capable to understand and respond to different intents and even unexpected inputs as well which gives them an edge over other platforms in the market.  
The future of AI assistants has ambitious plans to develop personalized assistants and autonomous organization of assistants, which will store sufficient information about every single user/customer. These are still under development and might come into existence as the field of NLP progresses. 

References: 

Further Reading: