Hi! Welcome back. In the previous video, I
introduced you to the broad concept of NLP
chatbots. In this video, we are going to narrow
our focus into a specific platform on which
we’ll build the bot. Dialogflow. To do this,
I’ll be referencing a full Pizza-order bot
that I’ve created as well as a couple examples
from other mini bots. So dialogflow is an
amazing (and free) resource for people of
all levels of expertise – from beginner
to advanced - to create NLP chatbots. One
of the best parts about it is that it does
not require any programming knowledge – so
just about anyone can try it out and build
their own bot! In this video, I’ll be walking
you through the basics of Dialogflow, which
comprise of these components. And note that
the words Agent, Chabot, and Virtual Assistant
basically mean the same thing, so I’ll be
using these words interchangeably. So the
first step to creating a chatbot on dialogflow
is creating an agent. An agent is a virtual
assistant that handles conversations with
users. Your job is to design and build an
agent to handle different types of conversations.
For example, on dialogflow, there are a series
of pre-built agents that each have a different
purpose. For example, this one looks like
it will take a coffee order, whereas this
one will set an alarm for a user. To create
your own agent, you simply head to the top
of the page and click on create agent. Now
im going to start a conversation with a pizza
ordering chatbot that I made. In the series
of videos right after I teach you the basics
of Dialogflow, I will walk through how to
build a pizza ordering chatbot similar to
this one. So let’s start a conversation
with this pizza-ordering bot and see how it
really works. So let’s start off with some
small talk. [type hi, response, good, response,
I’m hungry,] So as you can see, when I say,
“I’m hungry,” the bot recognizes my
intent (which is that I want food) and is
able to come up with this response. It is
able to do this because of what is known as
Intents in dialogflow. An Intent categorizes
user’s intent, or what they are trying to
say or ask. Each agent has several intents.
For example, this forecast intent recognizes
questions that users have about the weather.
Now you might be thinking, well can’t a
normal non-NLP bot understand intent as well?
A person could just program in a question
and the bot would have to detect whether the
user’s question matches the programmed question,
and if it does, then it would match the intent.
Well, yes, but this is highly inefficient
and limited. You see, in this example, these
two questions are basically asking the same
thing but are worded differently. A non-NLP
chatbot would not detect the second one as
matching the forecast intent because the words
don’t match the programmed question. To
fix this problem, one option would be to code
in numerous different types of questions to
try to cover all user potential questions,
so that the bot would be able to detect differences
like these. From a programmer’s standpoint,
he or she would have to create an if-then-else,
or rule-based bot, and manually handle all
possible scenarios through several OR statements.
But imagine just how much time, effort, and
extra work that would be, with the likely
outcome that it’ll never be exhaustive enough.
Well this is where NLP comes in. With a bot
powered by Natural Language Processing, a
person would not have to manually code in
hundreds of thousands of different variations.
Instead, they can type in a few sample questions,
Called training phrases, and when a user’s
expression resembles on of these phrases,
Dialogflow matches the intent. You don’t
have to define every possible example, because
dialogflow’s built-in machine learning expands
on your list with other similar phrases. Let’s
take a look at this concept in dialogflow.
So, on dialogflow, if we click on Intents,
we see a bunch of intents created for this
pizza bot. So this begin-order is the intent
that is called when someone mentions that
they are hungry, that they want food, that
they want pizza, etc. And if you notice, none
of these training phrases are exactly what
we typed in here “I’m hungry,” which
explains the power of NLP. Now if we scroll
up to the top of the page, we see something
called Contexts. Dialogflow contexts are very
similar to natural language contexts. For
example, if someone says, “I want it.”,
we need context to understand what the “it”
means. Now lets talk about an example where
the person wants to know the balance in his
checking account at his bank. So in this example,
the user wants info on their checking account.
When they say this statement, Dialogflow matches
it to the CheckingInfo intent and now the
Checking context is active for the next few
messages. And the duration for which it’s
active is known as the lifespan, which we’ll
talk about in a little bit. Next, Dialogflow
responds with a follow up question. To this,
the user states, “my balance”. Now in
a situation without context, the bot may be
confused as to why the user is saying the
words “My balance” out of the blue. But
now that it knows the contexts, it’s able
to match it to the correct intent and respond
accurately. In the Part 2, we will learn how
to build our own mini bot that shows the power
of context. Not only this, but we will also
build the same bot without context and see
the difference in the output. Now a little
while ago, I mentioned the word lifespan.
So the lifespan is basically a number next
to each context that indicates the number
of conversational turns that the context remains
active. If you don’t quite understand lifespan
right now, that’s ok because in Part 3,
I’ll be explaining it in more depth and
we will be building a bot from scratch that
will show why lifespan is important and what
happens if the lifespan is too little. So
far, we’ve covered agents, intents, follow-up
intents, contexts, and lifespan. Connecting
this back to the pizza ordering bot from the
beginning, these components allowed the bot
to match the user’s words to their desired
meaning and understand the context in which
the words were said. But what actually allows
the machine to figure out that “Brooklyn
style” is a type of crust and that “onions
and tomatoes” are forms of toppings? There
has to be a way for the machine to categorize
these words to figure out that the user is
giving it examples of the pizza component
it asked for, right? Well, this is where entities
comes into play. An entity is basically a
category that certain words fit into. In this
case, the bot extracts the three key words,
apples, bananas, and oranges, and is able
to classify these as a fruit entity. Let’s
look back at the pizza bot to understand this
concept a little more. So we left off at the
bot asking us what type of crust we’d like.
So as you can see, the bot gives us several
options for crust-type. In this case, crust
is the entity. We can then type in our crust
choice and it asks us for the size of the
pizza. and the size is the entity. [type]
Cheese is the entity in this case. After typing
this in, it prompts for toppings, and toppings
becomes the entity. entities make this bot
smarter because they allow the bot to recognize
not only the various samples I’ve included
here, but also much more. If you recall, I
mentioned garlic, and though that is not one
of the options here, it is able to recognize
that as a valid topping. Additionally, fuzzy
matching and automated expansion allows us
to misspell words, use incorrect grammar,
etc., and the bot will still recognize it.
Let’s see this in action with this bot.
So when it asked for crust, last time, I typed
in the whole phrase. But we don’t actually
need to do that. If we type in half of it
[hand], it still recognizes it and prompts
us for the next thing. Similarly, if we misspell
the size here [mmall], it will still detect
it. If we both cut the phrase in half and
misspell the cheese [shrded], it still recognizes
it. So as you can see, NLP bots have immense
potential to make our lives easier. And Dialogflow
helps us harness this potential by enabling
us to create a powerful chatbot. In this video,
we covered the most crucial aspects of Dialogflow.
In the last two videos of this series, we’ll
be building two mini bots. But these bots
aren’t just any random bots. They each serve
as an interactive way for you to deepen your
understanding on two essential concepts in
Dialogflow that are often harder to wrap your
head around than other aspects – these concepts
being Context and Lifespan. So not only will
you get to build two working bots, but you
will also get to fully understand and witness
the power of these two concepts in the next
two videos. Now if you’ve enjoyed learning
about Dialogflow in this video, give this
video a thumbs up and comment down below what
type of bot you’d like to build. I’ll
also be looking through the comments and making
tutorials and guides on some of the bots you
guys want to build – so make sure to let
me know what I can help with! And if you are
new here, then make sure to subscribe and
turn on notifications so you don’t miss
any videos that’ll help you on your journey
towards mastering artificial intelligence.
Thanks for watching, and I’ll see you in
the next one.
