Plato Data Intelligence.
Vertical Search & Ai.

A practical guide to Rasa chatbot — Part 02 (Building Covid19 Chatbot)

Date:

Rakesh Panigrahy

Hello my dear friends, hope you liked the first part. If you have not read yet then go and check it out. So hope you are in a fresh mood and let’s dig deeper into rasa chatbot. Wait wait wait, first download the code from the link for your reference. We will prepare our files one by one.

a. It will provide answers to FAQ regarding covid19.

b. It will provide us with symptoms check of covid19.

c. It will give us the status of people infected, recovered, dead with other additional information in states and districts of India.

d. It should be good to handle small talk.

  1. data/nlu.md

a. intent for providing reports for a particular place. Here Mumbai is the place type entity. It is written like this because we want to extract place name from a sentence.

b. intents for FAQ

c. intent for self-assessment

Alright, these are 3 important intents, we are interested in. You can add other intent of your choice.

2. data/stories.md

a. On trigger of covid_report intent we will call custom action i.e., action_covid_report using actions.py.

b. On trigger of faq intent we will call respond_faq action using response selector.

c. On trigger of self_assessment intent we will call self_assessment_form action and activate the self_assessment_form. After providing all the answers by the user the form will be deactivated.

Note:- Rasa forms are used when you want to ask some questions to the user in a sequential fashion.

3. config.yml

Here we use spacy for tokenization and entity extraction.

EntitySynonymMapper is to map different words with the same meaning.

ResponseSelector is used to select appropriate response from data/responses.md for faq intent.

1. 8 Proven Ways to Use Chatbots for Marketing (with Real Examples)

2. How to Use Texthero to Prepare a Text-based Dataset for Your NLP Project

3. 5 Top Tips For Human-Centred Chatbot Design

4. Chatbot Conference Online

FormPolicy is used to use Rasa Form.

4. domain.yml

a. intents and entities: Mention all the intents and entities as mentioned above.

b. slots: We want some information from the user to provide the probability of having covid19 like, whether he has fever, diarrhea, dry cough, etc. The user will answer as yes or no and that response will be mapped with respective slots. Here you can assume slots as variables to store responses.

c. responses: When you want to ask questions for slots then your action name should be utter_ask_slotname as below.

List out your actions and forms as below

Note:- The actions start with respond will return output from responses.md file and the actions start with action will return output from actions.py.

5. data/responses.md

For the action respond_faq, create a file responses.md as below

ResponseSelector in the pipeline selects appropriate response for the intents.

6. actions.py

Import necessary libraries in the file.

a. First register the class with actions by returning the action name in name function as below,

class ActionCovidReport(Action):def name(self) -> Text:return “action_covid_report”

b. When someone asks like, tell me COVID status in Odisha, then Odisha will be marked as an entity of type place. For each response, all the entities can be extracted from the run function as

tracker.latest_message[‘entities’]

c. Then that place will be searched in our API response and then we can respond back to the user by using

dispatcher.utter_message(text=message)

d. Similarly, when self_assessment_form will be triggered, questions will be asked by the bot. So we need to mention the sequence as below.

e. Then user response will be an affirmation or deny. So we will map those responses using slot_mappings as below,

If the response intent is to affirm then set the slot value as true or if it is denied then set the slot value as false.

f. After getting all the response from the user and mapping it to slots, extract those slot values either for storing it in the database or performing other operations in submit function as below,

6. endpoints.yml

In this file uncomment the following lines to run actions.py file,

7. creadentials.yml

Here also uncomment the line shown below to use it as API,

Alright, we are done with our setting part. Now our chatbot is ready to train. Train the chatbot using the command,

rasa train

Now it’s the time we were waiting for. Let’s run our chatbot and see how it responds.

Congratulation for building covid19 chatbot. On our next tutorial, I’ll teach you, how to move your Rasa opensource to Rasa X. We’ll also see, how to create and use Flask API to deploy your chatbot on your website.

Source: https://chatbotslife.com/a-practical-guide-to-rasa-chatbot-part-02-building-covid19-chatbot-593c955992c5?source=rss—-a49517e4c30b—4

spot_img

Latest Intelligence

spot_img

Chat with us

Hi there! How can I help you?