Let's build AI powered contextual chatbots with RASA: part-4
Hi all and welcome to fourth and final part of this RASA chatbot series.
We are all setup and ready to build our Restaurant search chatbot.
But before we dive in :
Let's have a look at what we covered in previous posts:
- Basic terminologies to build chatbot with RASA
- What is RASA NLU and RASA Core
- Setting Up a basic RASA chatbot
That was all we covered. If you have missed anything please checkout the above posts.
A bit about me 😄
I am a professional python developer working with W3sols (A web and mobile app development company)
I am experimenting with AI and ML based tech stack these days.
So let's dive straight into where we left our last blog post.
- We have a basic chatbot directory called restoBot
- We have environment active
Because we are building a restaurant search chatbot, we will have to use an API and here I will use zomato API
Here is the full zomato API doc zomatopy.py. Just put it in the chatbot directory restoBot. This doc will help us make API requests and from where we call the API ???
- I know you said it correct - actions.py
Copy and paste the code in actions.py to your actions.py in restoBot directory.
Now, what's happening here is that our actions.py makes a call to functions defined in zomatopy.py which in turn calls the zomato API.
One can check the whole chatbot at this repo.
All set !!!
Let's start coding
domain.yml
intents:
- affirm
- restaurant_search
- greet
- goodbye
- stop
- bot_challenge
entities:
- cuisine
- location
- price
- people
slots:
cuisine:
type: text
location:
type: text
templates:
utter_ask_cuisine:
- buttons:
- payload: Chinese
title: Chinese
- payload: Italian
title: Italian
- payload: South Indian
title: South Indian
- payload: North Indian
title: North Indian
text: what kind of cuisine would you like?
utter_ask_howcanhelp:
- text: how can I help you?
utter_ask_location:
- text: In what location?
utter_default:
- text: i cannot understand
utter_goodbye:
- text: goodbye :(
- text: Bye-bye
utter_greet:
- text: hey there! How may i help you
- text: Hi, How can I help you!
- text: Hey, How is it going. How May I help you Today
actions:
- action_search_restaurants
- utter_ask_cuisine
- utter_ask_howcanhelp
- utter_ask_location
- utter_default
- utter_goodbye
- utter_greet
nlu.md
intents:
- affirm
- restaurant_search
- greet
- goodbye
- stop
entities:
- cuisine
- location
- price
- people
slots:
cuisine:
type: text
location:
type: text
templates:
utter_ask_cuisine:
- buttons:
- payload: Chinese
title: Chinese
- payload: Italian
title: Italian
- payload: South Indian
title: South Indian
- payload: North Indian
title: North Indian
text: what kind of cuisine would you like?
utter_ask_howcanhelp:
- text: how can I help you?
utter_ask_location:
- text: In what location?
utter_default:
- text: i cannot understand
utter_goodbye:
- text: goodbye :(
- text: Bye-bye
utter_greet:
- text: hey there! How may i help you
- text: Hi, How can I help you!
- text: Hey, How is it going. How May I help you Today
actions:
- action_search_restaurants
- utter_ask_cuisine
- utter_ask_howcanhelp
- utter_ask_location
- utter_default
- utter_goodbye
- utter_greet
stories.md
## complete path
* greet
- utter_greet
* restaurant_search
- utter_ask_location
* restaurant_search{"location": "delhi"}
- slot{"location": "delhi"}
- utter_ask_cuisine
* restaurant_search{"cuisine": "chinese"}
- slot{"cuisine": "chinese"}
- action_search_restaurants
- slot{"location": "delhi"}
- utter_goodbye
- export
## location specified
* greet
- utter_greet
* restaurant_search{"location": "delhi"}
- slot{"location": "delhi"}
- utter_ask_cuisine
* restaurant_search{"cuisine": "chinese"}
- slot{"cuisine": "chinese"}
- action_search_restaurants
* affirm
- utter_goodbye
- export
## complete path 2
* greet
- utter_greet
* restaurant_search
- utter_ask_location
* restaurant_search{"location": "delhi"}
- slot{"location": "delhi"}
- utter_ask_cuisine
* restaurant_search{"cuisine": "North Indian"}
- slot{"cuisine": "North Indian"}
- action_search_restaurants
- utter_goodbye
## complete path 3
* greet
- utter_greet
* restaurant_search
- utter_ask_location
* restaurant_search{"location": "italy"}
- slot{"location": "italy"}
- utter_ask_cuisine
* restaurant_search{"cuisine": "chinese"}
- slot{"cuisine": "chinese"}
- action_search_restaurants
* goodbye
- utter_goodbye
## complete path 4
* greet
- utter_greet
* restaurant_search
- utter_ask_location
* restaurant_search{"location": "delhi"}
- slot{"location": "delhi"}
- utter_ask_cuisine
* restaurant_search{"cuisine": "chinese"}
- slot{"cuisine": "chinese"}
- action_search_restaurants
- slot{"location": "delhi"}
- export
## interactive_story_1
* greet
- utter_greet
* restaurant_search{"location": "mumbai"}
- slot{"location": "mumbai"}
- utter_ask_cuisine
* restaurant_search{"cuisine": "chinese"}
- slot{"cuisine": "chinese"}
- action_search_restaurants
- slot{"location": "mumbai"}
* stop
## interactive_story_1
* greet
- utter_greet
* restaurant_search
- utter_ask_location
* restaurant_search{"location": "mumbai"}
- slot{"location": "mumbai"}
- utter_ask_cuisine
* restaurant_search{"cuisine": "Italian"}
- slot{"cuisine": "Italian"}
- action_search_restaurants
- slot{"location": "mumbai"}
## interactive_story_1
* greet
- utter_greet
* restaurant_search{"cuisine": "chinese", "location": "delhi"}
- slot{"cuisine": "chinese"}
- slot{"location": "delhi"}
- action_search_restaurants
- slot{"location": "delhi"}
* affirm
- utter_goodbye
## happy_path
* greet
- utter_greet
* restaurant_search{"cuisine": "italian", "location": "mumbai"}
- slot{"cuisine": "italian"}
- slot{"location": "mumbai"}
- action_search_restaurants
- slot{"location": "mumbai"}
* affirm
- utter_goodbye
## interactive_story_1
* greet
- utter_greet
* restaurant_search{"cuisine": "chinese"}
- slot{"cuisine": "chinese"}
- utter_ask_location
* restaurant_search{"location": "delhi"}
- slot{"location": "delhi"}
- action_search_restaurants
- slot{"location": "delhi"}
* affirm
- utter_goodbye
endpoints.yml
configure end point for action server
action_endpoint:
url: "http://localhost:5055/webhook"
If you are not able to understand what all code is written above then please checkout earlier blog posts in the series.
Before the last step: Delete all the models present in models directory of restoBot.
At last !!!, train the model or as I say it "Let's train the chatbot"
Open two cmd prompts or two tabs in a terminal window
In first window :
$ rasa run actions
In second window:
$ rasa train -vv -dump-stories --force
It trains the NLU and CORE and stores a model in models directory of our chatbot
$ rasa shell
It runs our chatbot
Here is a liitle conversation with the chatbot
So that is it coders !!!
Congratulations 🎊 on creating your first restaurant search chatbot.
Until next time, HAPPY LEARNING !!!!
I cannot find nlu.md file. I have nlu.yml file