A good training process (that is, the process of defining training phrases) can help you build a robust Dialogflow bot.
You can actually break this process down into 5 steps. Breaking it down into a 5 step process has two advantages – it acts as a checklist when you are creating your Dialogflow bot. Second, by breaking down a complex process into individual steps, it helps you to keep things simple.
Here are the five steps:
1 Intent identification
Consider the PlanetsBot used in my step by step guide.
You can ask questions like these:
“what is the color of Mercury?”
“what is the volume of Jupiter?”
and so on.
Each of them gets a unique response. So we could start by looking at the number of planets (9, including Pluto) and 3 different attributes – (color, mass, volume). That makes a total of 27 different intents.
This is, of course, a very naive approach.
2 Entity identification
We notice that the questions follow the same pattern.
“what is the color of Earth?”
“What is the color of Mars?”
“What is the color of Mercury?”
So we decide to create an entity called Planet, and we can instead use a pattern like this:
“What is the color of planet X?”
That will simplify things a bit.
But we can also do the same thing with the attribute and simplify things a bit more.
Now our training phrase can simply be:
“What is attribute Y of planet X?”
We have reduced the total number of required intents from 27 all the way down to 1. 🙂
How to identify intents and entities?
While the two steps seem obvious and logical, you might be wondering how to identify these intents and entities for your use case.
For example, a common use case is to create an FAQ bot based on the live chat logs between your service reps and your users/customers.
Here is a tip (but don’t overuse it) – often, when people are typing out their requests, the “verb” in the sentence is an indication of the intent, and the “proper noun” in the sentence is often an entity. In fact, you can use the pattern “verb.noun” as a good representation for your intent names. E.g. “I would like to pay (verb) my bill (noun)”. Use this as a starting point and don’t be too rigid. You should try and adapt it to your specific use case.
I have created a tool which can actually help you identify these intents and entities from your chat logs. The output of the tool is a good example of what the verb+noun approach looks like:
3 Entity annotation
Now that we have decided that Planet and Attribute are going to be entities, we need to make sure that we tell Dialogflow to use them.
Dialogflow helps us in this process. When you type out a training phrase, it is able to automatically identify all the entities and annotate them. Here is an example inside the PlanetsBots. Notice how, as soon as you type the training phrase, Dialogflow automatically identifies and annotates (that is, defines word boundaries) for the Planet and Attribute entity.
As an aside, I frequently see a lot of people have unexpected annotations inside their intent definitions. Dialogflow is quite aggressive when it comes to annotating entities, so make sure you don’t end up with unnecessary or incorrect annotations. Unexpected annotations can reduce your bot’s accuracy in all kinds of unexpected ways.
4 Phrase grouping
Once you have identified your intents and entities, it is also important to provide a reasonable number of training phrases and make it easier for your chatbot to understand the user’s message.
As you can see, it helps to provide 10-20 training phrases in each of your intents.
Tip: You can type out a lot of training phrases very quickly inside a spreadsheet and use the BotFlo app to bulk upload them with the click of a button.
5 User utterance ingestion
One of the nice features of Dialogflow is its ability to take something the user said to your bot and make the bot “smarter”.
The video below shows how this process works. I am often surprised by how few people know that this is a feature in Dialogflow (and more importantly, how to use it to their advantage).
Check out my free Udemy course: Zoho Deluge Script Quickstart for Programmers
This website contains affiliate links. See the disclosure page for more details.
"The magic key I needed as a non-programmer" The custom payload generator was the magic key I needed (as a non-programmer) to build a good demo with rich responses in DialogFlow Messenger. I've only used it for 30 minutes and am thrilled. I've spent hours trying to figure out some of the intricacies of DialogFlow on my own. Over and over, I kept coming back to Aravind's tutorials available on-line. I trust the other functionalities I learn to use in the app will save me additional time and heartburn. - Kathleen R Cofounder, gathrHealth