Many innovators and developers can easily create a chatbot, then why would anyone will 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 rise 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.
So, let’s get started with the attraction part along with the development of chat bot. 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 learn 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 that 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.
Basically, as we all know 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 buttons.
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 modify 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
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:
– 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, title is the name that will be displayed to the user and the payload is the intent name which this button will refers 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 uaing “rasa train” and run it using rasa x and start taking to your bot and see Rasa X in action.
This is how your chatbot will work what you will run rasa x with your trained model.
I hope it was really helpful blog for you. But still if there are some queries related to the topic then leave a comment below in the comment section. Also provide your valuable feedback if you have like this post.
Till then Stay tuned and Happy learning.