Smart Chatbot Implementation using RASA

30 / Nov / 2021 by Sanmati Jain 0 comments

In the era of chatbots, besides imitating humans they can also perform complex tasks like booking tickets for movies etc. Out of various implementations, Rasa is an open-source implementation for Natural Language Understanding (NLU) and Dual Intent and Entity Transformer (DIET) models. It can interact with databases, APIs, conversational flows for interactive learning with reinforcement Neural network. 

In this study, various features of Rasa core are studied and up to much extent, it can perform complex tasks. Implementation details are studied like interaction with the database and API. Tracker Store has been examined by modifying the core file adding metadata to the user message data so that user IP and Port can be captured. Furthermore, the action, interactive learning and implementation details are tested on Pycharm IDE.

Rasa Conversational AI assistant is quite different from earlier traditional FAQ interactions as it is based on natural conversations means like how humans interact with each other by considering what earlier the context was sent and what actions are to be taken in reference to the contexts and gracefully handling the unexpected conversation and driving the conversation when the user drifts from normal conversation path and also improve over time thus it’s far beyond the FAQ Interactions.

 Rasa Conversational AI assistant normally consists of two components and they are Rasa NLU and Rasa Core. Rasa NLU can be just treated like an ear that is taking inputs from users and Rasa Core is just like the brain which will take decisions based on user input.

Applications of Chatbot

Chatbots today are being deployed across industries to assist customers (customer service), or engage with customers (sales and marketing), or do both. However, there are a few chatbot applications that are unique to each industry. Some key industries where chatbots are deployed are

  1. Retail and eCommerce
  2. Travel and hospitality
  3. Banking, finance, and fintech
  4. Healthcare
  5. Media and entertainment
  6. Education

Why Rasa?

Out of the different approaches tried, we went ahead with the RASA chatbot for implementation for HAWK (an internal platform). The main advantages of RASA over other chatbots are as below

  1. Free and open source
  2. Easy to Use
  3. Highly customizable
  4. On-premise, deploy on own server/compatible with all cloud platforms
  5. A growing community
  6. Can be integrated with popular messaging platforms

Features of Rasa

  • Extract meaning from messages
    Turn free-form text in the English language into structured data. Supports multiple intents and both pre-trained and custom entities. Fully customizable NLU for any domain, industry, or use case.
  • Hold complex conversations
    Retain important context and hold back-and-forth conversations using machine learning-based dialogue management. Smoothly handle topic changes and seamlessly integrate business logic into conversation flows.
  • Interactive learning
    Generate training data by talking to your assistant, and provide feedback when it makes an error. Easily share your assistant with test users.
  • Connect to commonly-used messaging channels
    Run your assistant on Slack, Facebook, Google Home, IVR, custom channels, and more. Serve multiple channels with a single assistant.
  • Integrate API calls
    Use Rasa’s custom actions to interact with APIs, databases, and other systems. Connect with knowledge bases, content management systems, and CRMs.
  • Leverage conversation-driven development
    Build customer-centred virtual assistants by incorporating user insights and engineering best practices into every part of your team’s workflow.
  • Version and manage models
    Track and manage your models promote to production or easily rollback. Integrate with automated testing and CI/CD.
  • Deploy anywhere
    Ready-to-deploy Docker containers and orchestration to run Rasa on-prem, or via a preferred cloud provider.

Rasa Component

  • Rasa NLU
    At this place, rasa tries to understand User messages to detect Intent and Entity in your message. Rasa NLU has different components for recognizing intents and entities of user messages, most of which have some additional dependencies. 
  • Rasa Core
    This is the place where Rasa tries to help you with contextual message flow. It can predict dialogue as a reply based on User messages and can trigger Rasa Action Server.
  • Rasa X
    It is a tool for Conversation-Driven Development (CDD), the method of listening to your user’s requirements or queries and then further using those insights to reinforce your AI assistant. It’s a browser-based GUI tool that will allow you to train a Machine Learning model by using GUI-based interactive mode. Rasa X is the latest release from Rasa that helps you build, improve, and deploy AI Assistants that are powered by the Rasa framework. 
    It layers on top of Rasa Open Source and helps you build a better chatbot assistant as per your specific requirements is a free, closed source tool available to all developers and can be deployed easily anywhere.

Project Scope

The Scope of the project is to gather the data from the Fresh Service knowledge base articles which contains almost all the issues faced by the different clients till now and then based on those knowledge articles to build/design a chatbot that can incorporate all the mentioned queries or issues. Hence, whenever a user or IT support team member needs to know the steps for the resolution of any query, they can directly chat with the bot instead of reaching out to any customer care or support executive.

Flow Chart

  • The message from the end-user is fed to the Rasa NLU (Interpreter) whose output is structured output containing the original text, the intent and entities if any.
  • The tracker maintains the conversation state and receives the structured output from the interpreter.
  • The output from the tracker is fed to the Policy, which acts on the current state of the tracker.
  • The policy decides which appropriate next action is to be performed.
  • The log of selected actions is maintained by a tracker.
  • The appropriate response is provided to the user, using intents defined in, like utter_response.

Rasa Architecture

Chatbot Workflow

The working of the bot at the backend whenever a user enters any query is shown in the diagram below :

The steps are :

  1. The user writes a query to the chatbot.
  2. The chatbot looks into the NLU file to search for the intents and the entities (if any) found in the user’s query.
  3. The bot tries to find the relevant story in the Stories file on the basis of the intents found from the NLU file.
  4. The bot finds the correct response corresponding to the intent referred to in the query and searches that response in the Domain file.
  5. The bot finds from the Domain file if any custom action is defined for that particular story/intent.
  6. If any custom response is written then the bot refers to the Actions file and utters a response to the user-defined in the Actions file.
  7. If any custom response is not written then the bot utters a response to the user from the Domain file.

Additional Features in Implementation

  • Addition of intents
    Added the account info and the intents for each query for a particular account and also configured the possible examples for each intent which the user can ask the chatbot. For example, I want to create new VPN users for production systems.
  • Addition of stories
    Added the stories in a way that possible multiple queries could be handled by the chatbot in a single conversation as well as individual queries.
  • Enabled the fallback policy for chatbot
    Fallback policy means what message the bot should utter to the user in case the user enters any unrelated or irrelevant query. For example, if a user asks “What is 2+2?” then the bot should utter “I didn’t understand that, kindly rephrase your query”.
    1. Account Security:
      Added a custom feature where a user of one account can only use the chatbot for queries configured in chatbot for that particular account. If the user tries to enter any query of another account then the response would not be visible to the user, hence making it more secure.
  • User’s Satisfaction:
    Once the query of the user is answered, the bot should pop up a message with YES/NO buttons asking whether the user’s query was resolved by the response given by the chatbot or not. 

For example, If yes, then utter a message “Great! Goodbye. Have a nice day!” 

If the user is not satisfied with the query’s response the bot should reply “Please contact a support executive for more help.”

  • Handling of wrong account name being entered
    If the user by mistake or intentionally provides the wrong account name then the bot must give a reply that the user has entered the wrong account name and request to enter the correct name. Once the correct account name is entered, the bot will utter the correct account name and will ask “how may I help you”.
  • Handling queries that are exactly not relevant
    Handling the query which is exactly not relevant (i.e. somewhat related to the configured queries in the chatbot but don’t have any response added for that) and provide the response for those queries. 

For example, query configured is “how to create a database backup” and instead 

the user asks “I want to create a database”, then the bot should ask/confirm whether the user wants to create a new database or to create a database backup. If the query response is configured then provide the correct response else utter that this query cannot be handled at that point of time or ask the user to be more precise.

  • Added the welcome message
    Whenever the user login into the HAWK portal and opens a chatbot window, he will be greeted by the bot with a welcome message.
  • Integration with frontend
    Integrated RASA backend code with Webchat widget (a React.js component for frontend) and modified the graphic user interface as per the HAWK’s theme.

Conclusion & Future Scope

From the study, it is concluded that rasa core features like slots, forms, supervised interactive learning, API integration, and database makes it a complete framework that can be used to perform highly complex tasks. The chatbot based on rasa has more capabilities than any open-source alternative. Further, in this paper, the internals of rasa has been modified to carry out custom data logging of client IP and port. All internals and custom action have been studied which further states that rasa is a completely open-source framework for the development of chatbots and for the developers who don’t want to dig into the internals of natural language processing.

In the future scope of this study, voice and face recognition engines can be integrated for more complex tasks like ATM cash withdrawal. Performance may be enhanced with the use of various learning procedures of machine learning.


Leave a Reply

Your email address will not be published. Required fields are marked *