Interactive chatbots using Rasa- the 3 step solution

Harshini Raju
CodeChef-VIT
Published in
4 min readJul 22, 2021

Artificial Intelligence has now reached a stage where integrating human-like personalities into AI services is the intention of the hour. A major contributor to ensuring the same is chatbots. Chatbots are essentially robots programmed to converse with humans and simplify life.

Creating a chatbot has been made very simple using Rasa Open Source. Using simple commands, providing minimal training examples and responses, an interactive and easy chatbot can be created with no hassle using Rasa. Once you install rasa on your anaconda environment following the instructions given in the Docs, you can begin your first project.

Before we dive into the specifics of the chatbot, there are some basic concepts of every rasa chatbot and they are:

Intent and Entities: In a rasa chatbot, the training data is given by intents- which are examples of the user messages, and entities-the keywords to be extracted from user messages and acted upon. The intent is stored in a YAML file(nlu.yml).

Story: It is a representation of conversational paths between the user and the bot. The stories are stored in a YAML file.

Domain: It defines the universe of your chatbot -specifies the entities, actions, responses, slots, and forms of your bot. The domain is stored in a YAML file.

Actions: The response to every user message is defined by actions. Responses are used when there is no processing to be down on the user message while custom actions process the user message and display specific output. Actions are stored in a python file.

When employing a chatbot, the major attributes are engagement and interaction. Rasa provides some features that make it easy to increase the interactivity of the bot.

1.Bot initiating the conversation

A catchy opening message plays a pertinent role in keeping the user engaged in the conversation. Using the basic rasa features such as the first story path and utterances (responses) can be a little tricky as utterances require a trigger from the user side. Hence, we will be employing custom action. UserUtteranceReverted is a class of rasa_sdk events that will revert all messages in the bot before the recent user message and set the next action of the bot as ‘action_listen’. This will help us in printing the first message when a conversation is started and the revert action caused by UserUtteranceReverted will prevent it from disturbing the flow of the conversation.

Example of UserUtteranceReverted() to intimate conversation

2. Employing Buttons

Buttons are a functionality of rasa that enables users to click directly on the bot messages without having to type their answers- this enables users to get involved in the conversation without having to spend time trying to type the exact commands that will get the answers. This is used in the domain file while specifying the utterance responses of the bot.

Buttons in response utterance

The “payload” key is the message sent from user to bot using the necessary intent for the next action and the “title” key is the message displayed on the screen for the user.

3. Using multiple utterance messages

The advantage of displaying multiple messages provides a sense of direction for the user and directs them towards their next step easily and also helps increase the engagement of the user on the website. But it is pertinent to ensure to keep these messages crisp and short enough.

This can be done in two ways:

Using custom action to display two messages

1.Using custom actions to display two messages and,

Using story paths to display two utterances one after another

2. Specifying story paths that will display one utterance after another

These three modest, yet effective, steps will help in enhancing the interactive factor of the chatbot and thus providing more personality. These can be further developed upon using the various features available in rasa and python functions too!

If you found this interesting please don't forget to leave a star!

--

--

Harshini Raju
CodeChef-VIT

I’m a computer science student interested in Data Science and IoT. I also have a passion for writing and am a budding content writer.