Adding Intents, Responses, and Stories

Now our chatbot can respond to basic user inputs, but we have to add more intents, responses, and stories to take email ID and Name from the user. For an in-depth explanation of intents, responses and stories refer to this article.

Adding Intents:

Here we need two new intents for name and email id. Add the below lines in your nlu.yml file.

- intent: email_id
  examples: |
    - [abc@gmail.com](email)
    - [abc@yourdomain](email)
    - @gmail.com
    - [xyz@gmail.com](email)
- intent: user_name
  examples: |
    - [YOURNAME](name)
    - [RANDOM_PERSON_NAME](name)

Here we are also creating two slots ( email and name) in which we will store the user data so in your domain.yml file add the new slots and intents.

Adding Responses:

Now we have to add two new responses to our chatbot.

  • To ask the user to enter name.
  • To ask the user to enter an email id.

For this add the below lines in the responses section in the domain.yml file.

utter_askname:
- text: Please enter your name.

utter_askemail:
- text: Please enter email id to receive updates.

Adding Stories:

Now we have to add some relevant stories in our stories.yml file so remove all the stories in that file and add the below lines ( you can add more stories according to your need).

- story: GeekforGeek story 
  steps:
  - intent: greet
  - action: utter_askname
  - intent: user_name
  - slot_was_set:
    - name: "YOURNAME"
  - action: utter_askemail
  - slot_was_set:
    - email: 'abc@gmail.com'
  - intent: email_id
  - action: action_email

Here ‘action_email’ doesn’t exist so we have to create this action to send emails but before that go to the endpoints.yml file and uncomment the lines below.

action_endpoint:
  url: "http://localhost:5055/webhook"

Send Automated Emails using Rasa chatbot

Rasa is a python module used to create custom AI chatbots. You can easily send automated emails to your users using the rasa chatbot. Rasa is a tool to build custom AI chatbots using Python and natural language understanding (NLU). Rasa provides a framework for developing AI chatbots that uses natural language understanding (NLU). It also allows the user to train the model and add custom actions.

In this article, we are going to see how to send emails using Rasa.

Flow Chart:

Similar Reads

Creating a Rasa chatbot

First, you will need a rasa chatbot through which you can send automated emails....

Adding Intents, Responses, and Stories

Now our chatbot can respond to basic user inputs, but we have to add more intents, responses, and stories to take email ID and Name from the user. For an in-depth explanation of intents, responses and stories refer to this article....

Adding Custom Email Action

Now we will add a new class in our actions.py file to send automated emails. Add the below codes in the actions.py file....