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

Making of Chatbot using Rasa NLU & Rasa Core-Part 2


Kindly check for Part 1, Part 2 and Part 3 for complete chatbot execution.

LEVEL 2: Creating an intermediate program using RASA Core and its dialogue management model where chatbot interacts at the command prompt level:

In LEVEL 1, we have learned about how RASA NLU interprets user input and extracts relevant intent and entity, but we are looking for a chatbot which interacts instinctually and continuously. Basically, User should be able to do chatting with a bot just like having normal communication or conversation. This can be achieved by RASA Core and let’s first understand the architecture of RASA Core.

  1. RASA Core Architecture:
Figure-5 RASA Core architecture
  1. The message is received and passed to an Interpreter, which converts it into a dictionary including the original text, the intent, and any entities that were found.

2. The Tracker is the object which keeps track of conversation state. It receives the info that a new message has come in.

3. The policy receives the current state of the tracker.

4. The policy chooses which action to take next.

5. The chosen action is logged by the tracker.

6. A response is sent to the user.

You can get further details in this link.

2. Creation of Domain File: The Domain defines the universe of the chatbot in which it is going to operate. It defines intents, entities, slots and actions. It will also include templates for the things your bot can say.

Figure-5 weather_domain.yml file

· We are already familiar with Intent and entities because we had already defined in our data.json file. The only different is here just we are only mentioning the name of them. Under Intent, we will mention different intent are getting used during the conversations like greet, inform, goodbye, etc. and entities will be location.

· Slots are like memory of a bot. They act as a key-value store which can be used to store information the user provided (e.g their home city) as well as information gathered about the outside world (e.g. the result of a database query or an API call).

· For example, if your user has provided their home city, you might have a text slot called location. If the user asks for the weather, and you don’t know their home city, you will have to ask them for it. A text slot only tells Rasa Core whether the slot has a value. The specific value of a text slot (e.g. Bangalore or New York or Hong Kong) does not makes any difference.

· Utterance templates are the messages the bot will send back to the user. There are 2 ways to use them.

i. if the name of the template starts with utter_, the utterance can directly be used like an action. You would add the utterance template to the weather_domain.yml file. Afterwards, you can use these template as if it were an action in the file.

ii. You can use the templates to generate response messages from your custom actions using the dispatcher: dispatcher.utter_template(“utter_greet”). We will be using this in our file for custom template.

· Actions are the things your bot runs in response to user input. There are three kinds of actions in Rasa Core:

i. default actions (action_listen, action_restart, action_default_fallback)

ii. utter actions, starting with utter_, which just sends a message to the user (see Bot Responses).

iii. custom actions — any other action, these actions can run arbitrary code

Here we have created class called ActionWeather and add as custom action using apixu website from where we are taking weather information.

Figure-6 file

3. Creation of Stories File:

· A training example for the Rasa Core dialogue system is called a story.

· A story starts with a name preceded by two hashes ## story_03248462. You can call the story anything you like, but it can be very useful for debugging to give them descriptive names.

· The end of a story is denoted by a newline, and then a new story starts again with ##.

· Messages sent by the user are shown as lines starting with * in the format intent{“entity1”: “value”, “entity2”: “value”}.

· Actions executed by the bot are shown as lines starting with — and contain the name of the action.

· Events returned by an action are on lines immediately after that action. For example, if an action returns a SetSlot event, this is shown as the line — slot{“slot_name”: “value”}


4. train_init and train_Online:

· We are going to use weather_domain.yml and files to train our RASA Core dialogue model. Both the files paths have been mentioned in file.

· Once training is completed, we are persisting or storing dialogue model related trained data into ‘./models/dialogue’ which will be used in train_online for execution.

Command: python


· Once the dialogue training model is generated, we will create file for giving online training to the chatbot.

· Here we are using ConsoleInputChannel libraries of RASA core which enables to train the chat bot through command prompt.

· We can train chatbot by making it understand whether the intent is correct, whether next action is correct and also if it is wrong then we can mention the correct intent and action so that chatbot will behave or act in this particular way. This all interaction can be stored into by choosing export.

· Command: python


5. Dialogue Management Model:

· This allows user to chat with Weatherbot through command prompt.

· Command: python


6. Understanding of important Keywords used in train_init, train_online and dialogue_management_model files:

· The agent allows you to train a model, load, and use it. It is a simple API that lets you access most of Rasa Core’s functionality.

· Policy is the core model architecture. A Policy will define what is going to be the next action. We have used here 2 policies:

i. Memoization Policy which will copy our training data and remember them by heart and then predict the next action.

ii. Keras Policy uses Recurrent Neural Network (LSTM) which takes features to predict next possible action.

· Maxhistory determines the number of feature set that is needed to be fed to the neural network. In order for the network to provide an output, we will need to figure how much in the past of the conversation does the policy needs to look back in order to determine what to do next in a conversation. By default, Max History is set at 5. Memoization policy will look back 5 steps in tracker to determine if next step matches with any stories in your training data.

Augmentation Factor determines the number of stories to be glued together randomly. You can skip this by setting up as 0 upon training. By default, value of augmentation factor is 20.

NOTE: For all the code I have added into this article are not aligned. Kindly refer to Github for actual code.

Kindly let me know your feedback or input to make this article much better along with your claps and also, if you are facing any issue regarding creating of Weatherbot.

Read More


Please enter your comment!
Please enter your name here