Chatbot Development Tutorial: Introduction of Intent, Stories, Actions in Rasa


What is Rasa?

The Rasa is an open-source Machine learning framework particularly developed for building chatbots. You can build your contextual assistant using Rasa. Rasa has the Machine learning-based approach to learn the conversational data.

In this tutorial we will see, how to install rasa, what are intents, stories and actions in rasa, and how to train and test the rasa model.

Install & Create Virtual Environment in Python

Install Virtual Environment

If you don’t have virtual environment, you can install it using following command :

sudo apt install virtualenv

Create and activate Virtual Environment

Before creating virtual environment, create a new directory/folder :

mkdir rasaDemo
cd rasaDemo

Now create the virtual environment by the given command :

virtualenv env_name --python=python3

Once you have created the virtualenv, activate it using the following command :

source env_name/bin/activate

Install RASA

You can install Rasa using the below command :

pip install rasa

Trending Bot Articles:

1. Conversational AI: Code/No Code

2. Chatbots 2.0: Simplifying Customer Service with RPA and AI

3. Question Answering on Medical conversation

4. Automating WhatsApp with NLP: Complete guide

Create RASA Project

Before creating Rasa Project make sure you are in the directory “rasaDemo”.

To create a rasa project run the following command:

rasa init --no-prompt

This creates the following files:

  • ⇒ an empty file that helps python find your actions
  • ⇒ code for your custom actions
  • config.yml ‘*’ ⇒ configuration of your NLU and Core models
  • Credentials.yml ⇒ details for connecting to other services
  • data/ ‘*’ ⇒ your NLU training data
  • data/ ‘*’ ⇒ your stories
  • domain.yml ‘*’ ⇒ your assistant’s domain
  • Endpoints.yml ⇒ details for connecting to channels like fb messenger
  • models/<timestamp>.tar.gz ⇒ your initial model

Note : The files with ‘*’ marked are the important files.


Intent can be understood as labels that are attached based on the overall goal of user’s message. For example, a user input ‘Hello’ or ‘Hi’ may call the intent ‘greet’. Training phrases are the user input, that for greeting users may say: ‘hello’, ‘hi’, ‘hie’, ‘hi there’ etc.

In Rasa, you can create the intent and add the training phrases in the data/ file. You can see some intents are already there in the file.

This is how file look like

## intent:greet
- hey
- hello
- hi
- good morning
- good evening
- hey there

## intent:goodbye
- bye
- goodbye
- see you around
- see you later

## intent:mood_great
- perfect
- very good
- great
- amazing
- wonderful
- I am feeling very good
- I am great
- I'm good

Where “greet” & “goodbye” are intent names, and they are defined using the (##) double hash followed by the “intent” keyword, and then below to it are the training phrases.


Stories are written in a specific format and stored in the file. When we create the rasa project, the file is automatically created in the data folder, the file has few simple training stories.

You will find aStories.mdthe file that contains story data. Stories are example of end-to-end conversations. Story has the structure where we have the user message and how our assistant will respond to those messages. We can also say that stories contain the flow of conversation.

This is how stories look like :

## happy path
* greet
- utter_greet
* mood_great
- utter_happy

Where happy_path is the name of the story, “greet” is the intent name and “utter_greet” is the action. Actions contain the bot responses.

Domain File

The domain.yml file contains the intent name and the action definition. The action name that we have used in the file i.e “utter_great” & “utter_happy” we will define that in this file.

This is how the domain look like :

- greet
- goodbye
- affirm
- deny
- mood_great
- mood_unhappy
- bot_challenge

- text: "Hey! How are you?"

- text: "Great, carry on!""

Train a Model

Anytime we made changes in the project we can train the model using the below command.

rasa train

Talk to your Assistant

Once the model is trained successfully, we can test it using the below command.

rasa shell

Using “rasa shell” you can test your assistant through the command line.

In the next tutorial, Chatbot Development Tutorial: Introduction Of Intent, Stories, Actions In Rasa X, we will see how we can use Rasa X to add the intent, responses, and stories using the UI.

Don’t forget to give us your 👏 !

Chatbot Development Tutorial: Introduction of Intent, Stories, Actions in Rasa was originally published in Chatbots Life on Medium, where people are continuing the conversation by highlighting and responding to this story.

Source link

Related posts

Aging Up, Not Out


Montreal-based VirtualMED bringing AI to virtual healthcare


#10: Deep Learning with Python


This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Privacy & Cookies Policy


COVID-19 (Coronavirus) is a new illness that is having a major effect on all businesses globally LIVE COVID-19 STATISTICS FOR World