Chatbot Advance
Chatbot Advance
Class Description Kids create their very first AI Chatbot using API programming
and integrating it with their app. This involves learning to train
the bot on user requests and developing appropriate bot
responses.
Class ADV-C38
Goal
● Student Resources:
○ Laptop/PC with WebCam
○ Use your Code.org login credentials
○ Earphone with mic (optional)
○ Notepad and Pen
1
Step 1: Hello! Ask the student to get into
Warm up the Fullscreen mode.
(5 mins) In the last class, we developed a
chatbot which greets a user and
shows a menu to the user when the
user asks for.
button at
the bottom-right corner of
your screen to start the
In-Class Quiz.
button will
appear on your screen.
2
Click End Quiz to close the
quiz pop-up and continue
with the class.
3
responses, something like: “I
don't understand” or “can you
say that again” etc.
4
1. Say Hi.
This training phrase is from the Welcome Intent. So the response is from the
Welcome Intent, which we created in the previous class.
This training phrase is from the menu intent. So the response is from the menu
intent, which we created in the previous class
3. Then ask the bot to show a review of any of the dishes mentioned.
5
This training phrase is from the Review Intent. So the response is from the
Review Intent, which we will be doing in this class.
4. Now I, being a user, can say ‘ok’ OR ‘wow’ OR ‘great’, and the bot will reply with
more information I can get about the dish, just to keep the conversation going.
This is also something that we will be doing in this class.
6
- Part 4: Create a Followup intent for the review intent - as you saw how the bot
was keeping the conversation going, this should also be done.
Now let's learn how to make some advanced things which I just showcased.
Let’s open the bot we created in the previous class.
NOTE: Open Teacher-Activity-3 and sign up using the Google account. Update
the Food-reviewer-bot which you created in the previous class as per the below
instructions.
1. Click to sign in with your Gmail account or your parents Gmail account
here. Use the same account that you used in the previous class. After signing in,
click to confirm.
Wow! Now we are using the Google Developer Platform where all google
engineers develop softwares.
7
3. You will see the bot I created last time: Food-reviewer-bot. Now let’s click on
8
➔ Part 1: Create a Review intent.
9
3. Save the Intent: Click to save the intent. .
10
5. Save the Intent: Great! Now click and let the bot train
itself.
The Review intent is successfully created. Now let’s test the bot.
Test the Intent: It's time to test the bot: Type your questions on the right where it
says -
11
- Test 1: Successful
- Test 2: Successful
Great!
12
➔ Part 2: Create an Entity.
Great! But don’t you think the user might ask for the review of a specific
food item?
In the last class, we created a menu intent where the user asked the bot
about the menu the restaurant has and the bot replied with the list of menu
it had.
Now the user might ask to show the review of a particular food item from
that list, for example: “Show the review of paneer tikka”
Now since there is no such intent nor we have trained the bot on what to do
in such scenarios, it will go in the default fallback intent, which will reply with
default responses such as ‘don’t know’, ‘can you come again’, ‘sorry I can’t
help you’. And the user will not get what he/she is actually looking for.
Hence the chatbot has this feature known as Entity which can be used to
handle such specific queries where the user wants information about a
specific item.
For example: Suppose, you are creating a chatbot on your collection of toys
so that you can share it with all your friends.
13
Friend - Which toys do you have in your collection?
Bot - I have many but few are my favorite ones which are - Barbie
Car, IronMan, and Fighter Drone.
So now let’s learn how to create Entity which can handle such specific
intent.
1. Create and Name an Entity: Let’s see how to create an Entity. Click
14
As the entity holds various dish names, therefore we have named
this entity as dish.
If you are creating an entity to hold the name of toys, then you can
name it as ‘toy’ OR ‘toyNames’.
2. Edit Entry: An entry holds the entity. Click Click here to edit entry.
Then add the reference name as a dish which will hold all the dish
names you want.
Now adding this dish reference will create a dish value in the
synonyms as well. Hover the dish value which is automatically added
in the Enter synonym section and delete the value.
If we don’t delete this synonym, the text dish will also be considered
as a food item name.
For example -
If a user says “Show me the review of a dish” instead of
© 2021 - BYJU’S Future School.
Note: This document is the original copyright of BYJU’S Future School.
Please don't share, download or copy this file without permission.
15
“Show me the review of Paneer tikka”, the text dish will be
considered as a dish name and the bot will mention the text
dish in the response as well. So it might give response like -
‘dish is rated as 5-star by 10,000 customers’.
Then add all the dishes that you want to add in the “Enter synonym”
section. Type the dish name and press Enter.
16
➔ Part 3: Connect the Entity with the Review intent.
Now we will add more dish specific training phrases to the Review intent so
that it also responds to the dish specific questions.
We are editing the Review intent so that it can respond to the food
item specific questions asked by the user.
3. Add Training Phrases: Add training phrases that you think the user
can ask while looking for a particular dish review. I have added 3
more training phrases for dish specific questions/training phrases.
You can add more training phrases which you think the user can ask.
17
4. Incorporate the Entity with the Training Phrases: Now let’s
incorporate the entity we created, with the training phrases.
○ When you select the text, a dialog box opens. In that dialog
box, search for the dish entity which you have created.
18
○ Select the entity name which is dish.
Similarly, do the same for all the remaining training phrases as well.
19
We had created an entity named dish which is stored as @dish. Now this entity
holds a few dish names - Paneer tikka, Paneer chilli, Chicken 65, Chicken
tandoori, and Veg Biryani.
So whenever the user enters any of these dish names, the bot will recognize these
dishes and accept the questions that match with the training phrases from the
Review intent and also check if there is a dish name entered by the user that is
also present in the @dish entity.
This way, whenever the user enters the dish names that are present inside the
entity @dish, the user-entered dish name is stored in $dish - Here, $dish acts as
a variable by storing the user-entered dish name.
Only the dish names stored in the dish entity will be recognized and stored
in $dish by the bot.
For example: If the user asks about a sandwich, this won’t be stored in
$dish, as ‘sandwich’ is not present in the dish entity.
20
5. Manage Parameters & Action: Now we should ensure that the user
enters the dish name, because food reviews can’t be generic. The
food reviews are about specific dishes. Therefore, to ensure the user
enters the dish name, we need to add a constraint to make sure that
the user enters the dish name which we have mentioned in the entity.
Hence, for this, we will use the Actions and the Parameter sections.
You will be shown either the above dialog box (then click on Manage
parameters and action) or the below section:
21
○ Enable the required checkbox:
22
○ Click Define prompts and it will open the following dialogue
box:
23
○ Then click on the button.
6. Now since the user’s question is food item specific, the response
should also be food item/dish specific. The dish name can vary
depending on the user's choice. So the bot should remember the
dish name. Therefore, the bot stores the dish name in $dish using
which you can refer to the dish name the user is referring to. Here
are a few example responses.
For example:
If a user wants the review of Paneer tikka, $dish will hold the value
“Paneer tikka”.
© 2021 - BYJU’S Future School.
Note: This document is the original copyright of BYJU’S Future School.
Please don't share, download or copy this file without permission.
24
And the output the bot will show is:
Note: Ask the student to add 2 to 3 responses. More, he/she can add later if
time permits.
25
Test the Intent: It's time to test the bot. Type your questions and see the
output.
- Try 1: Successful
- Try 2 : Successful
26
- Try 3 : Successful
- Try 4: Unsuccessful
This is a dish name which is not added to the entity. Therefore, it will
ask you to specify a dish name from the given list.
Great! You have learned to create an entity and incorporate it with an intent.
27
➔ Part 4: Create a Followup intent for the Review intent.
First, let me tell you what a followup intent means and what will it do?
So if a user asks for some review and he/she gets the review. What
should happen after that? How will the user know what is the next
step or what more can the user ask to the chat bot? For example -
Now, the conversion has ended. How will the user know what the next step
is or what more the user can ask to the chatbot?
Hence, we will add a followup intent which will help the conversion going
and give guidance to the user for the next step.
1. Move your mouse over the intent which you want to add a followup
for and click Add follow-up intent.
2. Select the custom followup intent. There are default followup intents
available as well, but they won’t be appropriate for our food reviewer
bot.
28
There is a high chance that after the bot shows the review to the
user, the user might reply with - ‘Okay’, ‘fine’, ‘cool’, ‘great’, etc. As
the bot is not trained to handle such responses, the bot will give
generic responses and it will not provide the response specific to
review. But since we want the conversation to keep going smoothly,
we will add a custom intent and rename it as Ok.
3. Then, add the training phrases for the custom intent that is
Review-Ok Intent:
29
4. Add responses to this followup intent:
30
Test the bot: It's time to test the bot. Type your questions and see the
output. First, ask about the food review and then say ‘Ok’ or ‘fine’ or ‘Wow’.
- Test 1: Successful
If you directly say ‘Ok’ before even asking for the review, it will reply with:
31
Hence, response to the phrase "Ok” depends on the previous intent,
therefore it is important when it is being said.
● Ask the Student to press the ESC key to come back to the panel.
● Guide the Student to start Screen Share.
● The Teacher gets into Fullscreen.
Student Activity
1-DIALOGFLOW
32
Remember, we are not creating
another bot. We are adding Intents to
the same bot that we created in the
last class.
1. Choose your bot: When you click on , you should see the list of bots we have
created in the previous classes. I am going to generate a link for Food-reviewer-bot but
you can choose any bot.
33
2. To Integrate this bot using link, click and enable Web Demo.Click
on
34
3.Click and you should get the following
4. The link in the src or source is the bot link. Copy this link and paste it in the panel and
35
press the Submit button.
You can also paste this link in another chrome tab and see how your bot looks and
works in real-time.
Great Job!
36
How does the bot work?
Step 5: Project Project name: MY CITY BOT Note: You can assign the
Pointers and project to the student in
Cues Goal of the Project: class itself by clicking on
(5 mins) the Assign Project button
which is available under
37
Today, you learned how to create an the projects tab.
entity and how to connect the entity
with an Intent.
Story:
38
That's all for today. I will see you in
the next class.
Bye Bye!
Teacher Clicks
39
Student Activity 1 DIALOGFLOW https://dialogflow.cloud.google.com/
40