Mastering follow-up intents with DialogFlow

Wassim Chegham
Google Developer Experts
4 min readNov 28, 2017

In virtually every CUI (Conversational UI), you—as a VUI designer—will need to take care of the users dialogues involving follow-ups and confirmations. Take for instance the following conversation:

  1. Me: “Hey buddy, I need a Caramel Macchiato.”
  2. StarBots: “Sure, I found a Starbucks within 2 minutes walk. Would you like me to order a Caramel Macchiato?”
  3. Me: “Wait, can I have extra whipped cream?”
  4. StarBots: “I’ve added an extra whipped cream to your order. Is that all?”
  5. Me: “Yep. You can place my order.”
  6. StarBots: “Done. Your Caramel Macchiato with extra whipped cream is waiting for you at Starbucks; You will shortly receive a confirmation email.”

Based on the “happy path” from this conversation, you can clearly identify the main intent (ordering a coffee), the secondary intents (adding extra toppings, order confirmation), the entities (Caramel Macchiato, cream) and context going around which allows the StarBots to keep track of the entities and user’s requests involved in this dialogue.

In order to design such dialogues, you will need to have, not only, a main intent that will match the user’s “asking for a coffee”; but also, secondary intents to handle “extras requests”, and orders confirmation (Yes/No). Thankfully, DialogFlow allows us to easily create these “secondary” intents. We simply call them “Follow-up” intents.

Let’s design this conversation using DialogFlow.

First of all, let’s create the main intent that will match the user’s order request such as “I need a Caramel Macchiato.”. We can also tag “Caramel Macchiato” as a custom entity we’ve created called “@coffee-type”:

Next, we’ll add a second intent nested inside the main intent, these nested intents are called “follow-up” intents.

Follow-up intent are normal intents that hold the context of their parent intent.

In order to add follow-up intents, simply hover your mouse over an intent and click on the “Add follow-up intent” label:

This will add a new intent nested inside the selected intent. We can choose from a wide variety of common follow-ups expressions such as confirmations, repeating, canceling…etc. Or, we can just add a custom follow-up intent:

Let’s get back to our conversation from above. We have two scenarios that we need to design:

  1. If the user just asks for a coffee and then confirms the order, we just need two intents: the main intent + a “yes” follow-up intent.
  2. If the user wants to add extra toppings, we then need three intents: the main intent + an “extra” follow-up + a “yes” follow-up (for the extra).

In the end, we’ll have something like the following:

  • user.order: our main “order” intent.
  • user.order — yes: a confirmation for the order.
  • user.order—extra: an intent for the extra toppings.
  • user.order—extra—yes: a confirmation for the order with toppings.

When adding follow-up intents, DialogFlow will automatically create:

  1. An output context in the parent intent (with a limited lifespan)
  2. An input context in the follow-up intent.

A lifespan of a context is the number of exchanges between the two participants.

These contexts are the same. They have the same name and act as a link between the two intents. This also means that you can access this context to read the arguments (entity values) they are stored in.

You can do that using the following syntax: #some-context.some-argument . For our scenario, this would be: #userorder-followup.coffee-type .

That’s All Folks!

Here is a quick demo of the “happy path” of our sample conversation, and all it took us is roughly 3 minutes to design and have an interactive demo we can iterate over an improve.

Follow me on Twitter @manekinekko to learn more about Chatbots, the Google Assistant and the Web platform.

--

--

Wassim Chegham
Google Developer Experts

#javascript @ Microsoft ★ GDE for Angular, Action On Google and GCP at Google ★ Member of Node.js Foundation and core contributor ★ Follow me @manekinekko