Best Practices for Managing Dialogflow Intents

Josh Barkin
Being Janis
Published in
7 min readMar 21, 2019

--

If you like this story, consider my Dialogflow Course

Dialogflow’s strength lies in its natural language processing and the content that is fed into it’s NLP engine is packaged into what Dialogflow refers to as “Intents”. Each Intent is essentially a JSON document with a web interface for managing the data.

I’m going to show you how to import Dialogflow Intents and share with you some strategies for managing your intents.

Importing Intents

You can create Intents directly in Dialogflow and you can export them as a ZIP file. You can also import a ZIP file with intents for your Dialogflow agent. If you have a ZIP file on your PC, it’s easy to import them to a Dialogflow agent.

Note that if you’re using a template, it’s a good idea to create a second Dialogflow agent just to import, edit and store template intents. Once you’ve edited the intents, you can copy them over to a Dialogflow agent that communicates with your customers. This way you’re not importing Intents to a chatbot that is actively communicating with your customers.

Step 1: Go to the Dialogflow console and click the ⚙icon next to your Dialogflow agent name.

Step 2: Click to Export and Import tab in the settings of your Dialogflow agent and click IMPORT FROM ZIP.

Step 3: Drag the ZIP file into the box and type the word IMPORT to complete the import.

That’s it. You’ve imported your Dialogflow intents and you’ll see them in your list of Intents. You can start working with your intents right away or keep reading for more best practices for intent management!

Naming Conventions

You’ll want to make it easy to manage a list of Intents by maintaining consistency in how you name your Intents. I generally name my Intents so they are grouped together, making it easy to access similar, or related Intents.

I like to give Intents with the same primary purpose the same name so they are grouped together. In the example above, I have a group of Intents that all are directly related to customer service, so I’ll use that as the first part of the Intent name. The second part of the name, separated by a period, will serve as a category and its purpose is to describe the function of the Intent.

For example, if the function of a customer service Intent is to understand when a user wants to order/purchase something, then I would name my Intent customerservice.order. If there is a secondary function, then think of that as a sub-category, and if the function of the Intent is to understand when a customer wants to lookup an order, my Intent would be customerservice.order.lookup.

Naming Intents this way allows me to quickly get an understanding of what the Intent does, while I can see and manage a relationship between similar Intents.

If my Dialogflow agent is just starting to take shape, I like to include version numbers in the Intent names. If you replace an Intent with a different Intent then Dialogflow will only look at the Intent name, not any of the other parts of the Intent to determine if the Intent is replaced. Version numbers allow me to maintain multiple versions of the same Intent, and then I can simply delete Intents I no longer need, or if I want to revert back to an older version of the same Intent, I can delete a newer version of it.

Managing intents with Context

With Dialogflow, you can know the context of a user’s message and deliver the right response. The challenge is that it can be a huge pain the *** to add context to similar Intents that are only differentiated by context.

For example, you might have an Intent that would trigger if a user says “Yes”, but you may want to use that intent in different contexts.

You’re going to want to create a copy of this Intent so that you’ll have two identical Intents. One of them will not have any context set and your bot can respond to “Yes” with a generic response. The duplicate Intent can have a different response to the same training phrases, but you will add context to that Intent.

I have to create two Intents and add the same training phrases to both Intents?

You would think that Dialogflow would just have a “Clone” Intent button so you could select the Intent and it would clone it and then you just need to add context to one of them.

Unfortunately, Dialogflow doesn’t have a clone button. You can only copy an Intent to another Dialogflow agent, or just move it from one Diaogflow agent to another.

You could download the Intent…

You could then open up the Intent (It’s a JSON file) and simply rename it.

Then you could upload the Intent you renamed and it will add your renamed Intent that way.

Store intents in a separate Dialogflow agent

The best strategy is to create a Dialogflow agent just to store intents. You can edit them there, add context, and then copy them back to your main Dialogflow agent for your bot. This way you don’t have to create multiple Intents and set up the same training phrases for each of those Intents just to add context. Create a new Dialogflow agent and call it something like “Development”.

Search for an Intent that you want to add context to. You can search by Intent name.

If you roll your mouse over an Intent you can select a checkbox. Click one, or more checkboxes to select Intents you want to copy over to your Development agent and click Copy.

From the pulldown menu select your Development agent and copy over any Entities too if you’ve created those so they remain associated with the Intent.

Once you’ve copied the Intent(s) over click to proceed to the agent.

You’ll see the Intent you copied over in a list of Intents in your Development agent.

Click into the Intent so you can now add context to it. You can see how you might add Context, and also you’ll want to change the name of the Intent so it reflects the context.

Now, save your Intent and go back to your list of Intents. Select that Intent so you can now copy it to the Dialogflow agent that you’re using for your bot.

Select your main Dialogflow agent from the list and copy the Intent and make sure you copy the associated Entities too.

Now you’ll see that you have two Intents that are identical, except the title of the Intent is slightly different (the name is similar so it’s grouped together) and one Intent has context while the other Intent doesn’t.

Wrapping up

Importing Intents: You can import ZIP files to a Dialogflow agent but note that choosing the restore option will replace all of your intents with the zip file you upload.

Naming Intents: It’s a good idea to name your intents like a “breadcrumb” where you can group intents together with similar names.

Storing Intents: It’s a good idea to have a Dialogflow agent just for development. You can import to this development agent, then copy over intents to your main Dialogflow agent. This way you can manage a template without having your customers communicate with a Dialogflow agent using templated responses, or you can make slight adjustments to differentiate similar intents (like adding context) and then you can copy them over to your main Dialogflow agent.

Before you go…

  1. Join the Janis.ai Facebook group and meet other Dialogflow users.
  2. Applaud and share this with others if you found it useful!
  3. If you like this story, consider my Dialogflow Course

--

--

Josh Barkin
Being Janis

Building conversational AI platforms since 2016