(0:00 - 1:06) I am preparing this video as a tutorial for getting started with Dialogflow ES and this is updated for 2021 and the main reason that I am updating it is because the one that I have on my website right now is fairly, it is not very new, it has been more than a year since I recorded it and I just wanted to update this and also I think that there are some things which I can explain a little better and a little easier. So, the first thing I want to mention is that this is a tutorial which will be useful for people who are not programmers because there will be no code involved at all in this entire tutorial. So, what I am going to do is if you go to this article I have on my site, you will be able to download a list of example agent zip files and what you will be doing is you will download this zip file and then load it into your Dialogflow console and then you will take a look at it and using that I will be explaining the concepts in Dialogflow.
(1:06 - 1:11) These are sort of like I said it is the basic concepts in Dialogflow. You have to start.
Intents
(0:00 - 0:16) You have to start with the understanding of intentsBoth Dialogflow ES and Dialogflow CX have the concept of int... More. So the first thing we are going to cover is what are Dialogflow intents. So what I will do is I will download this file and you can see that it downloaded as a file to my desktop.
(0:16 - 0:36) Then what I will do is I am here in my Dialogflow console and you can see that I have this agent called step-by-step tutorial. It just has the default intents which are created when you first create the agent. Then what I am going to do is I am going to go to this gear icon and we are in the settings view.
(0:37 - 1:23) So go to export and import and click on restore from zip, select file and the file that I am going to use is called step-by-step tutorial intents.zip. So let us open this, restore it and you can see that this is how I took the agent zip file from my website and I have made that as the agent we are going to use right now. So what you see here is that it imported a bunch of stuff into my agent. You can see that there are more intents, let us just click on one of these, it is just what is the color of earth, this is the name of the intent, you can see that the training phrase is also what is the color of earth and then the response is simply you ask for the color of earth.
(1:24 - 1:58) So the bot is merely echoing back what the user has asked and that is pretty much the entire thing, that is how I will be doing it for the rest of this tutorial also. So you can see what is the color of Jupiter, it is asking and then the bot says you asked for the color of Jupiter. Now what I want to do is you can actually start testing this straight away, you go to this integrations tab over here and scroll down and click on this Dialogflow Messenger square and you can then click on try it now.
(1:58 - 2:46) You can see that it has this Dialogflow Messenger chat widget and in fact you can interact with your bot straight away, what is the color of earth, let us say and it says you asked for the color of earth, which is correct, which is what we are asking for and then let us say what is the mass of Saturn and you can see that it should say you asked for the mass of Saturn. So it can answer three properties or attributes, color, mass and volume and for all the planets and we have nine of them, I guess some people will say that there are only eight planets but for the sake of simplicity I am going to suppose that there are actually nine planets. So this is the concept of an intent.
(2:46 - 3:25) So what is an intent? An intent is the intention that the, so the user wants to do something and the intent represents their intention, in this case the user is simply asking what is the color of a planet. You can think of an intent where some actionYou define an action in Dialogflow ES intents to tell your w... More has to be done, maybe somebody is going to talk to their Google home and they say turn on the light and the intention there is of course to turn on the light and you know you expect that something will happen as a reaction to what the user has said. So that is what intents are, intents represent things that the user wants to do.
(3:25 - 3:35) In some chatbot frameworks they call them skills and you will find that usually these concepts overlap. Now we have learnt about intents, let us talk about
Entities
(0:00 - 0:18) Let us talk about entitiesBoth Dialogflow ES and Dialogflow CX support entities and th... More. Now before I go there, I just want to point out something. You see that in the chat bot we have right now, there are actually a total of 29 intents and if you ignore the default intents which are created when you first start, that leaves us with 27.
(0:19 - 0:42) So it is basically 3 attributes multiplied by 9 planets and that gives us 27 different intents, right. But you also notice that it is all very repetitive, right. So it is all like the training process is always going to be what is the color of Saturn, the response is always going to be you ask for the blah of blah, you know this like the attribute of planet or something like that.
(0:42 - 1:04) So entities represent a way to group things together. So it is, they call it as concepts in the dialogue flow documentation and I think that is another way to look at it. But what I will say is that think of entities as sort of a way to group things together as a sort of a classification system, right.
(1:04 - 1:48) Now you can see straight away that one simple classification system we can have is we can group all the planets together and just have a way to represent them. So what we have to do for that is I am going to go to the next step in this tutorial and I am going to download the next agent zip file and you can see that it is called entity 1 that is the name of the zip file. So what I will do is I will go back to this gear icon here, go back to export and import and remember that when you do a restore it actually deletes the old agent and replaces it entirely with the new agent zip file that you are using which means that we will not see any traces of the old stuff.
(1:48 - 2:15) So let us go ahead and click on this restore again. So then when you are done with that if you go to the intents you will actually find that it is collapsed your 27 intents into just 3. So one of them is color of planet and so before I go there I have to show you the entities first. So if you go to the entities you will see that there is an entity called planet and if you click through on it you will see that I have declared an entity which looks like this.
(2:15 - 3:04) So these are you can think of these as the key of the entity and these are the values and I have all the 9 planets declared in the planet entity which allows us to do this which is you can say something like what is the color of earth and you notice that it actually annotates so dialog flow is smart enough to identify that this is an entity you have defined and it is going to annotate it by highlighting it with a specific color and then it is going to say that hey is this the entity that you are looking for. So to make it a little clearer let me do this tell me the color of Jupiter. So let us say I do that you notice that it is also able to annotate the word Jupiter and identify it as an entity.
(3:05 - 3:47) So once that is done what you can do is you reference the value of whatever was typed in by simply doing this in the response you say you ask for the color of and then when I type the dollar sign you notice that it is actually trying to do an autocomplete because it knows that it identified this planet attribute or rather the planet entity in the user phrase in the training phrase that was provided. So now that allowed us to get the color of the planet in the same way you have the mass of the planet and then in the same way you also have the volume of the planet. So we can see that this is how it is done.
(3:47 - 4:07) Now you go back to the integrations just to check if everything is working. So go to your dialog flow messenger integration try it now and you ask the question what is the volume of let us say Pluto. So you will see that it come back with you ask for the volume of Pluto.
(4:07 - 4:30) So far so good we can just try something else what is the mass of Mercury just to be sure. So you can see that it is all working let us close it. So now you might be wondering well given that we have collapsed the planets into one group why cannot we just also collapse the attributes themselves into a single group called attribute.
(4:30 - 5:14) So that is what we will do next. Let us go scroll a little further down and we will now download this agent zip file. Go back to the settings go to export and import restore from zip select file and I am going to go for entity version 2 let us restore this and now if you go and look at the intents notice that there is exactly one other than the default intents and as you might expect we will have an attribute called sorry an entity called attribute and inside that we have these three mass color and volume.
(5:14 - 6:22) So this allows us to further simplify the agent by basically we are now just have one single intent and in this case you can see if I say what is the color of Jupiter it was able to annotate both of them and get the two as separate entities it was able to identify that is dialog flow was able to annotate both the entities that you have in the training phrase. And then you do the same thing as before where you say you ask for the and then you put a dollar sign and follow that with attribute of and then another dollar sign followed that with planet that will be enough for you to echo back what the user was asking. So you go to the integrations tab and go to dialog flow messenger right now and let us check it what is the color of let us say Saturn then I will say what is the mass of let us say Neptune.
(6:24 - 6:43) So it is going to be able to identify these values of these entities and then it will echo back the actual whatever the user asked. So that is for entities. So now you understand what entities are and you also already understand what intents are supposed to be.
(6:43 - 6:45) Now the
Contexts
(0:01 - 0:22) Now, the next thing we have to learn is the concept of contextsContexts are used in Dialogflow ES to manage the state of th... More. Now, contexts are very interesting because they allow you to do two different things. The first thing that they allow you to do is they allow you to sort of pass information from one step of the conversation to the next.
(0:23 - 1:17) And the other thing they allow you to do is in fact, they allow you to guide the conversation along the path that you prefer, because you can use contexts to restrict if a specific intent can be, you know, used in the, at any given point in the conversation. Now, I have a lot of material about this topic on my website, and you can actually go and take a look at the concept of something I call as context, well, the stuff is called context lifespan, and that's not something that I call it like that, it's just the word that Dialogflow is itself uses, but I do use a concept called candidate intent. So, I don't want to go into too much detail right now, you should go and take a look at other tutorials on my site, but the main point is that you can use the concept of these contexts in Dialogflow ES to guide the, you know, the flow of your conversation.
(1:17 - 1:31) So, in any case, let's download this and save it. And now, I'm going to go back to the gear icon and restore the latest zip file. Let's go ahead and do that.
(1:37 - 1:56) So now, if you go to the intent view, you will see that there are, other than the defaults, there are three more intents. So, the first one is this attribute of planet, where the user is asking for the attribute of the planet, this is the same as the one we had before. But the one big difference is that we have set something called an output context.
(1:57 - 2:25) So, you will add that output context over here, and notice that the name of the context is called attribute hyphen set, okay. And then, you find that the response will simply be, you ask for the attribute of planet as before, but there is also another intent where the user changes the planet name. So, what has happened here is that we use the attribute set as the input context for this particular intent.
(2:25 - 2:52) And notice that we again use attribute set as the output context for this intent. This allows you to keep repeating the same process. And by that, what I mean is, notice that the user is now asking, and what about Pluto? But they are not actually telling the attribute they are interested in, they have changed the planet name, but they do not tell what the attribute name is, which means that this is being inferred from the previous step.
(2:52 - 3:19) That is basically how humans converse in a way, right, because, you know, if you hear a follow-up question, you can understand from the context or, you know, what went before, you kind of know what the person is talking about. So, this is a way to give that kind of power to chatbots. Now, it is possible to sort of overuse it and sort of over expect that this will solve a lot of these, you know, context related, I guess, specifications.
(3:19 - 3:29) That is actually not the case. This has to be very explicitly defined. It is not that simple to implement and you have to be doing it in a way which is very methodical.
(3:29 - 3:45) And you have to do it in a way which is, I would say, precise, okay. Anyway, so, what you can do then is in the response, you can use the syntax. You can say you ask for the, and then if you put the hash symbol, so let me just retype it so that it is clearer for you.
(3:46 - 4:13) So, you ask for the, and then you say hash symbol. Notice that the hash symbol is going to do an autocomplete of the context names which are available to use at that point. And then you can say attribute, which is the name of the entity for, and the dollar will do autocomplete for the training phrase entity, which was identified in this particular intent.
(4:14 - 4:25) So, I hope that you see the difference. The hash will allow you to use the context and then you follow that by the name of the entity of the previous step, while the dollar will do the same for the current step. Okay.
(4:25 - 4:35) So, that's why you do this, you change the planet and this is how the bot is going to respond. Now, you go to the changes attribute. It's somewhat similar.
(4:35 - 5:04) You know, you have to have the same input and the output context, but in this case, the training phrase will be, and what is its color, where the user has changed the attribute, but they want to use the planet from the previous step. Now, this time you'll say you ask for the dollar attribute of, because, you know, this attribute is coming from this training phrase. And then for the previous step information, we once again do the syntax where you do the hash sign followed by the context name dot the entity name.
(5:05 - 5:13) Okay. So, let's go ahead and check this and see if it works. So, the way you do that is go to the messenger integration, try it now.
(5:14 - 5:24) Now, what I'll say is, what is the color of Jupiter? Let's do that. Now, you have changed. So, you have asked for the color of Jupiter.
(5:24 - 5:37) Now, I'm going to change the planet. Okay. And what about Earth? So, notice that it was able to infer that color has already been specified as the attribute in the previous step.
(5:38 - 5:50) What has changed is the planet name. So, it's saying you asked for the color of Earth, which is correct, which is exactly what the user expected. So, now that we have asked for the color of Earth, let's try to change the attribute and use the same planet.
(5:50 - 6:16) And what is its mass? So, you can see that now it's asking, you asked for the mass of Earth. Now, let's do it one more final time and see if we can go back to Jupiter. And what about Jupiter? So, you can see that it's saying you asked for the mass for Jupiter, which is exactly what this, at least according to this conversation, that's what the user has intended.
(6:16 - 6:32) So, the context has allowed us to get information from previous steps and use it in the following steps. That is the, you know, one of the big reasons to use the context. And as I mentioned, context is also useful for guiding the conversation flow.
(6:32 - 6:43) That's a much more involved topic. And I would like to suggest that you go and read the tutorials on my site to get more information about that. And one last thing that I want to mention in this...
Integrations
(0:00 - 0:24) One last thing that I want to mention in this tutorial is the concept of integration. So what are Dialogflow integrations? Notice that when you go to this, you know, this tab, it mentions all these integrations which are available in Dialogflow. So this is something which you have to understand, which is that in and of itself Dialogflow is just a chatbot framework.
(0:24 - 0:41) It provides you all the software to do what they call as natural language understanding or NLU. But it's not going to be having a user interface all by itself. The integrations are what provide the user interface.
(0:41 - 0:52) So you just saw the Dialogflow messenger integration. There's one more called the web demo. And if you take a look at it, you can actually click on this link and you'll find that it takes you to a page.
(0:52 - 1:08) And you can actually interact with the bot in the same way here. You know, what is the color of Jupiter? You can ask the question. And you see it comes back with you ask for the color of Jupiter and what about Mars, you know, and so on.
(1:08 - 1:22) You can keep going like that. And in fact, you can use this little voice thing to even input your query by voice. It's not going to be 100% perfect, but it's actually pretty decent.
(1:23 - 1:40) So the thing is, this is what gives the user interface to your chatbot. And that's something that I've noticed people are not very clear about. So integrations are what allows people to actually interact with your chatbot.
(1:40 - 2:10) So that brings us to the end of this, I hope, useful tutorial. And this is the, you know, that brings us to the end of this tutorial, which I hope is going to get you started quickly. One of the main reasons that I made this style of tutorial is because instead of getting bogged down in understanding concepts and, you know, not going very far, my view is that if you see something working, it will, first of all, you know, you get something working.
(2:10 - 2:39) So that's your positive sort of feedback loop. But also, I think that you will be able to go in and, you know, explore your agent and sort of ask yourself questions like, hey, what is going on here? What is happening with this? And you can see that by using the integrations, you're also going to be able to actually interact with your chatbot and not just in the simulatorYou can use the Simulator in both Dialogflow ES and Dialogfl... More. So this stuff on the right is called the simulator, but you want to also interact with your agent with the actual user interface.
(2:39 - 3:08) So that was the, you know, an important goal of this tutorial. And once you go through this whole tutorial, then you can also go to this, the page where I have written this, and I am going to have a lot of references for this tutorial at the end of this, so that you can sort of, it's sort of next steps for what you might want to read and what you might want to explore after you have learned the basics of Dialogflow ES.
Note: This is my old website and is in maintenance mode. I am publishing new articles only on my new website.
If you are not sure where to start on my new website, I recommend the following article: