0% found this document useful (0 votes)
4 views40 pages

Chatbot Advance

The document outlines a class for kids to create their first AI chatbot using API programming, focusing on training the bot to respond to user requests. The class includes a structured approach with warm-up activities, teacher-led demonstrations, and student-led practice, culminating in the creation of intents and entities for a food review chatbot. Resources required include laptops, web cameras, and Code.org login credentials, with a total class duration of 55 minutes.

Uploaded by

Usha Rani N
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views40 pages

Chatbot Advance

The document outlines a class for kids to create their first AI chatbot using API programming, focusing on training the bot to respond to user requests. The class includes a structured approach with warm-up activities, teacher-led demonstrations, and student-led practice, culminating in the creation of intents and entities for a food review chatbot. Resources required include laptops, web cameras, and Code.org login credentials, with a total class duration of 55 minutes.

Uploaded by

Usha Rani N
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Topic CHATBOT ADVANCED

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

Class time 55 mins

Goal

● Develop an AI based Chatbot by adding entities to the


Intents.

Resources ● Teacher Resources:


Required ○ Laptop/PC with WebCam
○ Use your Code.org login credentials
○ Earphone with mic
○ Notepad and Pen

● Student Resources:
○ Laptop/PC with WebCam
○ Use your Code.org login credentials
○ Earphone with mic (optional)
○ Notepad and Pen

Class Structure Warm Up 5 mins


Teacher-Led Activity 10 mins
Student-Led Activity 30 mins
Wrap Up 5 mins
Project Pointers and Cues 5 mins

Start the video call from H2H

Class Steps Say Do

© 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.

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.

I have an exciting quiz question for


you! Are you ready to answer this
question?

Please click on the

button at
the bottom-right corner of
your screen to start the
In-Class Quiz.

A quiz will be visible to both


you and the student.

Encourage the student to


answer the quiz question.

The student may choose the


wrong option. Help the
student think correctly about
the question and then
answer again.

After the student selects the


correct option, the

button will
appear on your screen.

© 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.

2
Click End Quiz to close the
quiz pop-up and continue
with the class.

Can you tell me, what is User


Intent?

User Intent refers to the Encourage the student to


intention of the users while answer.
interacting with a chatbot.

Let me show you something.

Teacher Initiates Screen Share

Step 2: Open Teacher Activity


Teacher-Led 1-BOT DIAGRAM.
Activity
This is a data flow diagram.
This is how dialogflow chatbots work.

(10 mins) 1. A user asks something.


2. The bot gets the user input
and matches the words with
the intents that are created.
3. If the words/phrases entered
by the user match the bot's
training words/phrases, the
appropriate set reply is
displayed.
4. If the user input
words/phrases don’t match
the training phrases/intent
questions, then the bot
displays the FALLBACK intent

© 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.

3
responses, something like: “I
don't understand” or “can you
say that again” etc.

Do you remember what we


learned in the last class?

We learned about the Welcome


Intent, Fallback Intent, etc. and
created a menu intent.

Can you tell me which intent is


the default intent, that is the intent
which gets created with the agent
itself?

Welcome Intent and Fallback


Intent

In this class, we will be creating an


entity and adding that entity to the
intent. And we will also learn the
follow up intents.

Now let me showcase what I said.


Open Teacher Activity 2-
SHOWCASE.

© 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.

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.

2. Then ask for the menu.

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.

© 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.

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.

Let’s understand how we can achieve this.

In this class, we will create:


- Part 1: Create a Review intent - which will show the review of a dish
- Part 2: Create an Entity - which will be used to get the dish name entered by a
user.
- Part 3: Connect the Entity with the Review intent - we will integrate the review
intent with the entity which will help us to train the bot to show the review of a
particular dish.

© 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.

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.

2. Click on the top-right corner to go to the Developer


Console.

Wow! Now we are using the Google Developer Platform where all google
engineers develop softwares.

© 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.

7
3. You will see the bot I created last time: Food-reviewer-bot. Now let’s click on

Intents and you will see the pre-built default


Intents and the menu Intent that we created in the previous class.

© 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.

8
➔ Part 1: Create a Review intent.

1. Create and Name the Intent: Click and


name the Intent as Review. This should answer the questions about
the review for food items.

2. Add Training Phrases: Under Training phrases, I am going to add

questions that the user might ask. Click


, type the phrase, and hit ENTER to add a phrase. Add as many
types of questions the user might ask about the food review.

Here is what I added-

© 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.

9
3. Save the Intent: Click to save the intent. .

4. Add Response: Now let’s set the response by clicking on

© 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.

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 -

© 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.

11
- Test 1: Successful

- Test 2: Successful

Great!

Now click and you will see the Review intent


enlisted.

© 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.

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.

So one of your friend might ask -

© 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.

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.

Friend - What is a Barbie Car?


Bot - It is very unique and it is voice controlled.
By looking at this, you can understand how we can train our bot to
give information on a specific item.

Similarly, we will create an entity for the food item.

User- Can you show me a food item review?


Bot - Which dish would you like to get the review of? Paneer tikka,
Paneer chilli, Chicken 65, Chicken tandoori, Veg biryani.

User- Paneer Chilli?


Bot - Paneer Chilli is one of the top dishes from our restaurant and
has been loved by most of our customers.

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

and then click on the CREATE


ENTITY button.

Now set the entity name.

© 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.

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 something like this appears:

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’.

Hence to ignore such cases, always delete the extra value


automatically created in the synonym section while adding the entity.

Then add all the dishes that you want to add in the “Enter synonym”
section. Type the dish name and press Enter.

We have specified 5 dishes. We have mentioned these 5 names


because in the menu, we are showing these 5 names to the user.
You can mention your favourite dishes. And you can add any number
of dishes you want to.

3. Save the Entry: Click to save the entry.

Great! Your entity is created.

© 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.

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.

1. Go to the intent section by clicking on Intents.

2. Click on the Review intent.

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.

© 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.

17
4. Incorporate the Entity with the Training Phrases: Now let’s
incorporate the entity we created, with the training phrases.

○ Select the text “dish” from the training phrase.

○ When you select the text, a dialog box opens. In that dialog
box, search for the dish entity which you have created.

© 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.

18
○ Select the entity name which is dish.

Similarly, do the same for all the remaining training phrases as well.

© 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.

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.

© 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.

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:

© 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.

21
○ Enable the required checkbox:

○ Then click on $dish which is under the value column:

Select the $dish.original option. Selecting this option will get


the dish name entered by the user (for example: paneer tikka)
and store it in $dish. Else, just the plain text ‘dish’ will be
displayed even if the user enters the dish name (for example:
paneer tikka).

○ When enabled, a prompts column will be displayed.

© 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.

22
○ Click Define prompts and it will open the following dialogue
box:

○ Enter the message that you want to be displayed if the user


doesn’t specify the dish name.

© 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.

23
○ Then click on the button.

So basically, this is a validation to check if the user enters a dish


name which is not present in the bot. In that case, the bot will reply
with the above response to show the user the list of dishes to be
picked. This is done so that there is a smooth flow and the user is
guided well.

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.

‘$dish has a 5 star rating and it is one of our top dishes.’

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:

‘Paneer tikka has a 5 star rating and it is one of our top


dishes.’

This is how we will get the dish specific response.

○ Let’s add more responses to the Review intent:

Note: Ask the student to add 2 to 3 responses. More, he/she can add later if
time permits.

○ Now, save the intent by clicking on the button.


© 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.

25
Test the Intent: It's time to test the bot. Type your questions and see the
output.

- Try 1: Successful

- Try 2 : Successful

© 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.

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.

© 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.

27
➔ Part 4: Create a Followup intent for the Review intent.

Now let’s add a followup intent to 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 -

User: ‘I want the review of Chicken 65.'


Bot: “Chicken 65 is the best selling dish of our restaurant with
a 5 star rating.”
User: ‘Okay’ OR ‘Thanks’.

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.

© 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.

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:

© 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.

29
4. Add responses to this followup intent:

Now, you might think why, in response, I have mentioned the


quantity, spice level, and preparation time. Reason being, we need to
direct the user with further conversation.

© 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.

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:

© 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.

31
Hence, response to the phrase "Ok” depends on the previous intent,
therefore it is important when it is being said.

We have successfully trained the bot.


.

Teacher Stops Screen Share

Now it's your turn. Please share your


screen with me.

● 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.

Step 3: Now, login to your dailogflow by The student is expected to


Student-Led clicking Student-Activity-1 and let’s build the entire bot on
Activity make your bot smarter. his/her own with the
teacher’s guidance
wherever required by
making sure that the student
(30 mins) follows the steps shown
above.

Student Activity
1-DIALOGFLOW

© 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.

32
Remember, we are not creating
another bot. We are adding Intents to
the same bot that we created in the
last class.

1. Create a Review intent.


2. Create an Entity.
3. Add the Entity to the Review
intent.
4. Add a followup intent to the
Review intent.

Generating the Chatbot Link (Follow the steps below):

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.

© 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.

33
2. To Integrate this bot using link, click and enable Web Demo.Click

on

You should get a pop-up showing the bot link:

© 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.

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

© 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.

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!

Teacher Guides Student to Stop Screen Share

Step 4: Okay! So let's quickly go through


Wrap-Up what we have applied today.
(5 mins)
Great! You have been really great
today and therefore you have earned
some hats-offs for yourself.
(Give atleast 2 hats-offs)
Press the Hats Off Icon for
Creatively Solving
Activities.

Press the Hats Off Icon for


Great Question.

Press the Hats Off Icon for


“Strong Concentration”.

© 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.

36
How does the bot work?

1. A user asks something.


2. The bot gets the user input
and matches the words with
the intents that are created.
3. If the words/phrases entered
by the user match the bot's
training words/phrases, the
appropriate set reply is
displayed.
4. If the user input
words/phrases don’t match
the training phrases/intent
questions, then the bot
displays the FALLBACK intent
responses, something like: “I
don't understand” or “can you
say that again” etc.

We will learn how to integrate this bot


with an app so that you can share it
with your friends and publish it on
Play store and app store.

Teacher Initiates Screen Share

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

© 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.

37
Today, you learned how to create an the projects tab.
entity and how to connect the entity
with an Intent.

In this project, you will have to


practice and apply what you have
learned in the class and create a
chatbot for your own city. Create an
entity with 1 value that is your city
and 3 intents. One for best places in
your city, one for best restaurants in
your city, and one for best shopping
centers in your city.

Story:

A reputed travel company in your city


is going digital. They have hired you
to create a Chatbot for them. The
chatbot needs to provide information
about your city to first-time travelers
so they can plan their visits better.
Think about all the things a traveler
needs to know to make the city
experience great - main attractions,
eat-out places in your city, famous
people, the best time to visit, etc.

The project will take only 30


minutes to finish. You can try and
finish it immediately after this
class.

I am very excited to see your project


solution and I know you will do really
well.

© 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.

38
That's all for today. I will see you in
the next class.
Bye Bye!

Teacher Clicks

Additional Add more responses to the Review


Activities Intent and the FollowUp Intent of the
Review intent.

Note to the teacher for the Next Class C39:

1. Check the student’s pending projects.


2. If the student has more than 3 pending/expired projects:
○ You can conduct the NEXT CLASS as a PROJECT COMPLETION CLASS.
○ Reach out to the concierge in advance for the same.

Activity Activity Name Links

Teacher Activity 1 BOT DIAGRAM https://curriculum.whitehatjr.com/ADV+Asset


/BOT+Diagram+Flow.png

Teacher Activity 2 SHOWCASE BOT https://console.dialogflow.com/api-client/dem


o/embedded/52425ab3-d3ad-4ebd-b412-33
0f2f800c2e

Teacher Activity 3 DIALOGFLOW https://dialogflow.cloud.google.com/

© 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.

39
Student Activity 1 DIALOGFLOW https://dialogflow.cloud.google.com/

Project Solution MY CITY BOT https://console.dialogflow.com/api-client/dem


o/embedded/6e5e275f-d97c-4a0a-ae65-b3b
8c6154419
This is an example of the city mumbai. You can
do it using your own city.

© 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.

40

You might also like