Basic Chatbots Using RASA

Iishi Patel
ACM VIT
Published in
3 min readJul 1, 2019

Chatbots have already become our best friends, personal assistants and what not. In fact it is known that they will soon be replacing all apps and web services and perhaps people too. Not only personal use but it can automate a lot of customer care services, saving companies a lot of money. In this article I will introduce you to making a basic restaurant reservation bot using RASA’s framework, coded in python.

What is RASA ?

RASA is a machine learning framework used to build chatbots and contextual AI assistants. RASA has two parts:

· RASA-NLU: Understands what the user wants to say and their intentions.

· RASA-CORE: Manages the dialogue flow and continues the conversation.

Understanding RASA-NLU

RASA-NLU is like the ears of the system. It uses open source natural language processing for intent classification and entity extraction. Intents contain the training data about what the user would say. This is saved as a markdown file which makes it easy for humans to read and write.

Next we have to make a configuration file which basically defines the components that RASA will use. Incoming messages are processed by a sequence of components which are executed one after another in a so-called processing pipeline. The required pipelines are stored in a .yml (just another file format) file.

Finally we load our training data and train it according to the given configuration file.

Dialogue Management

Dialogue management is handled by RASA-CORE. It is considered as the brain of the system. Here we make actions which deal with the responses of the bot to the user’s input. There are three types of actions we can use:

· Default Actions: For example, ‘action_restart’.

· Utterances : These are hard coded responses to a particular input of a user.

· Custom Actions : These are logic involved actions , such as validation of information and calculating amounts.

After this we make stories in a markdown file (.md). Stories contain the flow of the conversation. They determine the response made by the bot based on the user’s input. We try to make stories with all the possible outcomes or directions in which a conversation could go.

We also make the domain file (.yml) where we mention all the components of our model.

We once again train our model over the stories and actions we just created.

Running of the Application

Our training is completed and we are ready to initiate a conversation with our bot. First we run the actions file with the following command on the command line(terminal):

python -m rasa_core_sdk.endpoint — actions actions

Lastly, we run the following python code to talk to the bot.

For the actual codes and training data files refer to my Github Repository.

For more information you can also take a look at RASA’s official documentation:

--

--

Iishi Patel
ACM VIT
Writer for

Research Lead @ ACMVIT. Machine Learning and Deep Learning Enthusiast.