Echo Dot (3rd Gen) - Smart speaker with Alexa - Charcoal

Use your voice to play a song, artist, or genre through Amazon Music, Apple Music, Spotify, Pandora, and others. With compatible Echo devices in different rooms, you can fill your whole home with music.

Buy Now

Wireless Rechargeable Battery Powered WiFi Camera.

Wireless Rechargeable Battery Powered WiFi Camera is home security camera system lets you listen in and talk back through the built in speaker and microphone that work directly through your iPhone or Android Mic.

Buy Now

Chatbot Development Tutorial: Introduction of Intent, Stories, Actions in Rasa | by Pragnakalp Techlabs

0
71


Pragnakalp Techlabs

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 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 rasaDemocd 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

You can install Rasa using the below command :

pip install rasa

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

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:

  • __init__.py ⇒ an empty file that helps python find your actions
  • Actions.py ⇒ code for your custom actions
  • config.yml ‘*’ ⇒ configuration of your NLU and Core models
  • Credentials.yml ⇒ details for connecting to other services
  • data/nlu.md ‘*’ ⇒ your NLU training data
  • data/stories.md ‘*’ ⇒ 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/nlu.md file. You can see some intents are already there in the nlu.md file.

This is how nlu.md 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 stories.md file. When we create the rasa project, the stories.md 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.

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

This is how the domain look like :

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

responses:
utter_greet:
- text: "Hey! How are you?"

utter_happy:
- text: "Great, carry on!""

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

rasa train

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.



Read More

LEAVE A REPLY

Please enter your comment!
Please enter your name here