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

chatbot development tutorial 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

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 a the 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.

Rasa Shell

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.

Feel free to comment your doubts/questions. We would be glad to help you.

If you are looking for Chatbot Development or Natural Language Processing services then do contact us or send your requirement at We would be happy to offer our expert services.

Categories: Chatbots Development

Leave a Reply

Your email address will not be published.

You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>