PRIYANKA VERGADIA: Hey, everyone.
I am Priyanka Vergadia, and you are watching
"Deconstructing Chatbots."
In today's episode, we will explore entities further.
[MUSIC PLAYING]
From the second and third episodes,
you might remember that entities are Dialogflow's mechanism
for identifying and extracting useful data from user's input.
If you've not checked out the episode
on "Getting Started with Dialogflow,"
please do so for more context.
Just scroll up to the second episode on the right,
or click in the link and description below.
There are three types of entities-- system entities,
developer entities, and session entities.
Now you might remember from our appointment scheduler chatbot
when we said need an appointment for 4:00 PM tomorrow,
the date and time were automatically
extracted as system entities date and time.
It was all automatic.
As you saw, system entities allow
agents to extract information about a wide range of concepts
without any additional configuration.
Data like address, emails, currency, phone numbers
are some of the common examples of system entities.
Now so far, we have been addressing our appointment
scheduler in a generic manner.
Let's say our scheduler is for DMV.
We click on Entities and create a new entity.
Let's call this Appointment Type.
Let's think about the types of services DMV offers.
Most people go to the DMV for a drivers license,
maybe vehicle registration, also driving tests.
So in our scenario, let's stick to the two main services--
drivers license and vehicle registration
are obviously the two main ones that I
can think of that DMV offers.
So let's create those two as entities.
You can add more rows with more services as entity types.
Additionally, you can check the box
to add more entities automatically.
When an entity is not available in the entity list,
Dialogflow identifies that this is an entity based
on other training phrases and adds that new entity
automatically to the list.
You can also upload or download entities in bulk
in CSV or JSON format.
Now let's add more intents to accommodate the appointment
type entity in our inputs.
When you add Set an Appointment for Driver's License for 3:00
PM tomorrow, driver's license is identified as developer entity
that we just set up, while time and date are obviously
system entities.
Add a few more training phrases like these.
Now remember slot filling from episode three
when we built our appointment scheduler?
To book an accurate appointment, we
needed to make appointment type a required field
just like time and date.
Let's define the right prompt for when a user does not
provide us the appointment type.
Now while we are at it, let's modify our response
to include the appointment type along with the date and time
to make it look more complete.
When done, don't forget to save your changes.
And then, let's test our updates now with some sample inputs.
The first example, let's say, user only
gives us the appointment type.
Well, slot filling kicks in and asks for the time and the date
when they want to come in.
All looks good.
We get the appointment scheduled.
In the second example, let's say, a user says,
I need an appointment for 4:00 PM tomorrow
without providing us the appointment type.
Again, our slot filling kicks in and prompts the user
to provide us the service information.
They say driver's license, and we
provide them a response with their appointment confirmation.
In our third and last example, let's say
the user gave us all three things
we needed in just one shot-- set an appointment for vehicle
registration at 2:00 PM tomorrow.
Our bot has everything it needs, so it
sends a confirmation response back to the user right away.
Now the third type of entity is session entity.
These are defined at session ID level, which
allows for a specific entity to be tied
to a user and their session.
Let's take an example to understand this better.
Our agent had appointment type as entity,
which includes drivers license and vehicle
registration at this point.
That entity could be updated to include a state
ID or a motorcycle test depending
on the information your agent collects from the user
during the conversation.
The updated session entity will have state ID or motorcycle
test entry for rest of the conversation with your user.
Well, try this out on your own, and let
me know how it goes in the comments below.
Remember, you will create, manage, and update
session entities using the API.
That was a lot, so let's summarize.
Today, we looked at the three types of entities--
system entity, developer entity, and session entities.
Then, we went hands on and learned
how to set up these entities in our appointment scheduler
chatbot.
Don't miss the next episode of "Deconstructing Chatbots"
because we are going to integrate our appointment
scheduler with Twilio Messaging Service.
[MUSIC PLAYING]