×
Vasishtha Ingale
Senior Software Engineer
Vasishtha is a Senior Software Engineer at Nitor Infotech. He has a keen interest in assimilating statistical approaches for Data Science. ... Read More

I hope you read and enjoyed my previous blog titled ‘Introduction to Rasa X’ since it is a precursor to this one. In case you haven’t, you can read it here.

In this blog, I am going to lead you through the installation, folder structure, controls, and features of Rasa as well as Rasa X to develop an assistant.

Let’s first dive into installing Rasa.

Installation of Rasa

To install Rasa, you require Python 3.7 or Python 3.8. Firstly, you need to create and activate a new virtual environment by giving this command:

C:\> python3 -m venv ./rasaenv

Activate it with: C:\> .\rasaenv\Scripts\activate

Once the installation is done, generate a folder structure for the Rasa project by typing rasa init in command prompt.

After initializing the structure, a developer can start customizing the basic chatbot that is included in the initialized folder.

Training Data in Different Files of Rasa Folder

1. NLU File

Intent is a class for a given set of examples which helps the assistant identify the user query. These examples are specified in the nlu.yml file. For example, if a user wants to stop a conversation, then you can define the examples as follows.

2. Domain file

The file domain.yml includes the following things:

  • Entities and slots: These are examples like City, Size of Pizza, Email Addresses, etc.
  • Form: This includes a structure to fill information automatically from user input
  • Responses: Here all the possible responses are defined, and a name is given to each one of them. Responses are named starting with utter for e.g. If a response is ‘order’, then conventionally it is written as utter_order.

3. Stories file

This file includes all the conversational flows designed and developed by a developer which helps the chatbot to make decisions in accordance with the stories. Stories are some ideal paths which illustrate the flow of the conversation can be. By gaining expertise in writing these stories, you can improve the performance of an assistant.

4. Rules file

The rules.yml file has rules for a specific conversation. For example, if a user wants something which is out of scope for the bot to answer, then any rule can handle the situation. Once the training data is updated, you must train the model on top of it which is saved in the folder.

The following image shows the folder structure of a Rasa chatbot. Every time the training is done, the new model is saved so all the past models can also be utilized.

Now it’s time to explore the second tool in our arsenal – Rasa X!

Installation of Rasa X

For Rasa X installation in Windows OS, we need to first install the Microsoft Visual C++ compiler. After that, we can go to the command prompt, activate the virtual environment created while installing Rasa and type the following command:

To check whether it has been installed correctly or not, navigate to the chatbot folder, open the command prompt and type rasa x. It will open a window in your default browser with GUI.

Features of Rasa X

1. Easy writing of training data

Instead of writing the training examples in a code editor or IDE, you can directly specify your data using GUI. In the above example, we defined the book_flight intent and gave an example of what a user can say. You can add as many examples as you want and save them.

2. Interactive learning

Interactive learning involves looking into what the intent was (identified by the bot) and then correcting it and manually guiding the bot to give responses. This way the bot creates automatic stories and can train itself further.

3. Records all previous conversations

To analyze earlier conversations and their flow and performance, Rasa X stores all conversations. In a live deployment monitoring user response and accordingly making changes in the training stories is a crucial step to have a successful chatbot in place.

4. Visualizes what’s going on in backend

The above image shows the Rasa X chatbot in the image. When the user said ‘Hello’, you can see that the bot identified the user intent as ‘greet’ which can be seen through this beautiful UI. Also, the next intent is to book a flight and then at the end you can see that a form is initialized to ask the user about the city from which he wants to book a flight and so on.

5. Slots identification

In the above example, once the user has confirmed that he wants to book a flight and the form has started to fill, the assistant asks about the departing city and automatically extracts the city from user input text with a confidence of (1.0) which means 100 percent sure.

6. Buttons

In the above image, you can see that once the user gives all the details about cities that he wants to depart and land at, the assistant gives a query in backend and communicates the dates available and shows the buttons of available dates and asks the user to select a suitable date which makes the conversation very easy. In case the user is not interested in these dates, then the bot can identify it and will recommend some new flights or just close the conversation as per the story.

7. Actions

actions.py is a Python file which handles connection with external sources like database, csv file or API. It tracks the slots and can read or write to files in accordance.

All the actions are defined as a class in the file. The above code snippet is an example of saving all the slot information in a csv file once the conversation is done.

I hope that after reading this blog, you are quite familiar with the controls and features of Rasa and Rasa X, and a sample as well. Now once you have understood the structure, you can develop and customize a chatbot according to your use case.

Explore how our AI chatbot helped a top European business management solutions company, efficiently manage compliance requests.

Feel free to get in touch with us at Nitor Infotech if you’d like to share your experience and suggestions. You can also discover more about how artificial intelligence and machine learning can make a real difference for your products, solutions, and services here.

subscribe image

Subscribe to our
fortnightly newsletter!

we'll keep you in the loop with everything that's trending in the tech world.

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it. Accept Cookie policy