Easy Steps 2 integrate API in Rasa chatbot for the user

0
0

Technology is everywhere…? Technology is everything…? Technology is with everyone…? In this generation where technology is everywhere and it is so important that the competition is at its peak. So in this huge competition, we must know how to grab the audience’s attention so that the user will choose your technology (Rasa chatbot for now) over any other technology. To learn and understand these ways to grab the audience’s attention we need to attract the audience first with the best UI that we can offer to our user. To understand this I have come up with this and the upcoming posts to make you learn different ways to attract and grab the Audience to your technology (Rasa chatbot for now).

OVERVIEW

In this post you will learn how to add the custom links to your Rasa chatbot so as to provide another way to interact with the user and to add extra features to the chatbot like the one that you will learn here is href links to redirect to the URLs.

Introduction

Link or we can also call it as the hyperlink is an icon, graphic, or text that links to the other webpage or URL. We have two ways of doing this, one is to directly display the link to the user to use further or to use it as the hyperlink and set any keyword as a reference to that link and that will hide the link from the user. We will cover both the ways in this post and I’m sure you will love it when you will use it with your Rasa chatbot. Now let’s understand what actually happens when you add the links in your Rasa chatbot.

Working

When you add the links to your rasa chatbot what happens is rasa in the backend use its a configuration file which we have with us as config.yml where there is a configuration for the regular function that checks whether the specified text is a link or not if that part is a link then it will be highlighted and will be treated as a hyperlink just like you may have done in the HTML where we use the <a href= “link-to-the-webpage”> tag to create a link. By default if you don’t specify the keyword for the link then the complete link is treated as a keyword otherwise the key is used as a reference to the link.

To learn the practical implementation of this over video the check out this video session and be an expert on this topic.

Let’s learn how to implement it in Rasa. Before starting let’s keep one thing clear in our mind that what we are going to do in this post.

For now, let’s assume that chatbot(as a waiter) and the user(as a customer) is having a conversation to place the order and suddenly the customer asked the waiter that I would like to know more about your restaurant so the basic information a waiter can easily give but to have a good impact for the restaurant the waiter decided to tell the customer about their restaurant’s official website so that the customer can check himself and get to know more and detailed about the restaurant. So, here is a small conversation for that that I’d like to add to my chatbot.

 User: I would like to know more about your restaurant.
Chatbot: Here is a link for you to know more about our restaurant: “http://www.innovateyourself.in/

So, this is a small chat that we will add to our existing rasa chatbot that we have created till now from our previous post. From this above chat now you may have a basic idea that where we have to make further changer for this chat to be implemented in our rasa chatbot. So, for this, we will make changes in the nlu.md, domain.yml, and stories.md file.

For the user text, we have to create a new intent in the nlu.md file so that our rasa chatbot can understand the text said by us and for the text said by the chatbot, we have to make changes in the domain.yml file. For this conversation to work we have to add a new story to the existing story so that our chatbot and give response accordingly.

nlu.md file after adding the changes:

## intent: more_info
- i want to know about your website
- tell me more about your site
- what about your website
## intent:what_do_you_have
- what can i get here?
- what can i have to eat?
- what can i get for the lunch?
- what is this place famous for ?
## intent:vegetarian
- vegetarian
- pure veg
- pure veggie
- i want vegetarian food
## intent:non_veg
- non-veg
- non-vegetarian
- pure non-veg
## intent:order_name_veg
- get me 1 mix veg and paneer butter masala
- i want 1 mix veg and masala mushroom
- i want green salad
## intent:order_name_non_veg
- get me 1 egg curry and chicken butter masala
- i want 1 egg fry and fish curry
- i want 5 boiled eggs
## intent:greet
- hey
- hello
- hi
- good morning
- good evening
- hey there
## intent:goodbye
- bye
- goodbye
- see you around
- see you later
## intent:affirm
- yes
- indeed
- of course
- that sounds good
- correct
## intent:deny
- no
- never
- I don't think so
- don't like that
- no way
- not really
## intent:mood_great
- perfect
- very good
- great
- amazing
- wonderful
- I am feeling very good
- I am great
- I'm good
## intent:mood_unhappy
- sad
- very sad
- unhappy
- bad
- very bad
- awful
- terrible
- not very good
- extremely sad
- so sad
## intent:bot_challenge
- are you a bot?
- are you a human?
- am I talking to a bot?
- am I talking to a human?

stories.md file after adding the changes :

## happy veg path
* greet
- utter_botgreet
* what_do_you_have
- utter_veg_non_veg
* vegetarian
- utter_veg
* order_name_veg
- utter_anthingelse
* deny
- utter_thanks

## happy non vegetarian path
* greet
- utter_botgreet
* what_do_you_have
- utter_veg_non_veg
* non_veg
- utter_non_veg
* order_name_non_veg
- utter_anthingelse
* deny
- utter_thanks
## happy info path
* more_info
- utter_info

Here I have added a separate story for this conversation phrase so that it won’t create any interference with the other stories.

domain.yml file after adding the changes:

intents:
- greet
- goodbye
- affirm
- deny
- mood_great
- mood_unhappy
- bot_challenge
- what_do_you_have
- vegetarian
- non_veg
- order_name_veg
- order_name_non_veg
- more_info
templates:
utter_info:
- text: “Here is the link to our website: http://www.innovateyourself.in/”
utter_botgreet:
- text: How can i help you sir?
utter_veg_non_veg:
- text: 'what would you prefer:'
buttons:
- title: Vegetarian
payload: /vegetarian
- title: Non-Vegetarian
payload: /non_veg
utter_veg:
- text: 'Here are the meals for you:'
image: https://youtu.be/qJDlttqmiXk
utter_non_veg:
- text: 'Here are the meals for you:'
image: https://media-cdn.tripadvisor.com/media/photo-s/12/3e/7c/5f/non-veg-starters-menu.jpg
utter_anthingelse:
- text: Is there any thing else sir?
utter_thanks:
- text: Thanks. We will get your order shortly.
utter_greet:
- text: Hey! How are you?
utter_cheer_up:
- text: 'Here is something to cheer you up:'
image: https://i.imgur.com/nGF1K8f.jpg
utter_did_that_help:
- text: Did that help you?
utter_happy:
- text: Great, carry on!
utter_goodbye:
- text: Bye
utter_iamabot:
- text: I am a bot, powered by Rasa.
actions:
- utter_greet
- utter_cheer_up
- utter_did_that_help
- utter_happy
- utter_goodbye
- utter_iamabot
- utter_botgreet
- utter_veg_non_veg
- utter_veg
- utter_non_veg
- utter_anthingelse
- utter_thanks
- utter_info

With this changes in the domain.yml file we will get the output like this:

and if the utter_info is written like this

utter_info:
  - text: Here is the link to our [website](http://www.innovateyourself.in/)

then your bot will give output like this:


So, these are the two ways how you can create or add the links in your rasa chatbot.

When you are done with this just train your model with the following code and run you rasa chatbot in the terminal by typing the commands.

 $ rasa train
$ rasa x
HYPER LINKS IN RASA CHATBOT
Output with hyperlink
LINKS IN RASA CHATBOT
Output without hyperlink

This is how your rasa chatbot will work when you will run rasa x with your trained model. These are the images with and without the hyperlink.

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.

Time to wrap up now. Hope you liked our content on How to integrate Rasa chatbot on Microsoft Azure. 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 Enjoy 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.

2 thoughts on “Easy Steps 2 integrate API in Rasa chatbot for the user

Leave a Reply