Add Payload Buttons to Rasa chatbot Easily <3

chatbot PAYLOAD
0
0

Many innovators and developers can easily create a chatbot, then why would anyone give you the chance to develop a chatbot for them. This is the main question why? This question will lead to molding yourself which will raise you up and this will make yourself stand apart from the crowd. So we should also know how to present the software that we develop. As in the first look attraction works that will give you the chance and then your work will speak.

OVERVIEW FOR PAYLOAD BUTTONS

So, let’s get started with the attraction part along with the development of chatbot. In this post, you will learn how to add multiple payload buttons to your rasa chatbot to make it more attractive and to start your journey towards the most valuable and attractive chatbot.

In the last post, you must have learned how to customize your chatbot in your way and build a chatbot of your choice. Now I can assume that from the previous post it is clear to you how to modify or make changes to the domain.yml, nlu.md, and stories.md file. Also, it will be clear to you that when and why do we make changes to these files.

Introduction

Basically, as we all know payload buttons are the inputs that are given when we click or touch them. Here also we are going to use them as an input to the bot when the user will click/touch the given button and each button will associate to it’s action specified.

So, how does this button works in Rasa, and what are the specified actions here? Now let’s understand the working of the payload buttons.

Working

Here what happens is when buttons are added the acts as the inputs and with each input there is a specific action specified in the form of intent name called as the payload which is being called when the button is clicked or touched. With each action and intent name is called which refers to the existing stories and then corresponds to the next action to be taken by the bot. That you will learn in this post. For the practical implementation check the video to understand it better.

In this post we will focus on the question that the bot has asked in the conversation, that is,

 “What would you prefer veg or non-veg?”

which we have named as “utter_veg_non_veg”. Now we have two options here which corresponds to two different menus vegetarian and non-vegetarian, so, we can modify this question in the form of buttons so that the user can directly click the button and get the menu as per the choice.

Now from this question which we have modified one, this is very clear to us that as this is a response of the chatbot so we have to go to the domain.yml file to make changes and to add the button to it.

As for now our new question will be

chat waiter PAYLOAD

Now we have to implement in such a way to get this result. Right now we have our domain.yml file as :

intents:
- greet
- goodbye
- affirm
- deny
- what_do_you_have
- vegetarian
- non_veg
- order_name_veg
- order_name_non_veg
templates:
utter_botgreet:
- text: How can i help you sir?
utter_veg_non_veg:
- text: what would you prefer veg or non-veg?
utter_veg:
- text: we have mix veg, paneer butter masala, mushroom masala,etc?
utter_non_veg:
- text: we have egg curry, chicken butter masala, fish curry, boiled eggs, bread
omlette, etc?
utter_anthingelse:
- text: Is there any thing else sir?
utter_thanks:
- text: Thanks. We will get your order shortly.
utter_goodbye:
- text: Bye
actions:
- utter_goodbye
- utter_botgreet
- utter_veg_non_veg
- utter_veg
- utter_non_veg
- utter_anthingelse
- utter_thanks

and from this we have to modify:

utter_veg_non_veg:
  - text: what would you prefer veg or non-veg?
SO, here what we have to do is just change it to :

utter_veg_non_veg:
- text: 'what would you prefer:'
  buttons:
  - title: Vegetarian
    payload: /vegetarian
  - title: Non-Vegetarian
    payload: /non_veg

Here, the title is the name that will be displayed to the user and the payload is the intent name which this button will refer to when the button will be clicked according to the existing stories. When this part is done we don’t have to make any further changes in any of the files. Now just train the model using “rasa train” and run it using rasa x and start talking to your bot and see Rasa X in action.

Payload buttons in rasa chatbot

This is how your chatbot will work what you will run rasa x with your trained model.

Time to wrap up now. Hope you liked our content on How to add payload buttons to Rasa chatbot. See you in our next blog, thanks for reading our blog and do leave a comment below to help us improve the content to serve you all of our experience with you. Stay tuned with us for more Rasa Chatbot contents.

Also check out our other playlist Rasa Chatbot, Internet of things, Docker, Python Programming, etc.
Become a member of our social family on youtube here.

Till then Stay tuned and Happy learning. 🙂

Ashish Saini
Ashish Saini

I am a software developer for Python/Machine Learning. Also, I’m Rasa Hero at Rasa. Also, I’m a youtuber where I regulary uploads the videos to help this generation learn about the technology just like they are playing games.

One thought on “Add Payload Buttons to Rasa chatbot Easily <3

Leave a Reply