Home / DialogFlow / Dialogflow tutorial: How to move to the next intent?
DialogFlow

Dialogflow tutorial: How to move to the next intent?

Sometimes I see questions like these in the Dialogflow forum.

So, I got one intent working. How can I now “move” the conversation to the next intent?

Answer

In Intent1, declare an output context called contextA. In the next intent you want to fire, use contextA as the input context. You have now chained Intent1 and Intent2 using contextA.

Is that all?

There is quite a bit more. But that’s the basic idea for every intent you are trying to chain into the conversation.

A practical example

I need to get three values from the user – their given name, their last name and their zip code.

I will be using the naming convention I mentioned in my previous post.

Step 1: The Welcome Intent

As soon as the user says Hi, the Default Welcome Intent will respond with a question asking for the user’s given name. The output context is set to awaiting_first_name

Step 2: Get first name

In the next intent, we get the first name. We use awaiting_first_name as the input context, and set awaiting_last_name as the output context.

When the user types in their first name, since the awaiting_first_name input context has already been set, and considering that the user’s input matches the expected pattern (i.e. they typed in something which can be recognized as the first name), it triggers the UserProvidesFirstName intent.

Can some other intent possibly fire during this step?(Hint: Yes) Read my article about intent candidate selection and leave a comment on what you think.

Step 2: Get last name

In the next intent, we get the last name. So here, we set awaiting_last_name as the input context and set awaiting_zip_code as the output context.

Just like in the previous step, if the user types in something which can be identified as a last name, the UserProvidesLastName intent will be triggered.

Step 4: Get Zip Code

Finally, we will get the zip code in the next intent. Here, we set awaiting_zip_code as the input context, and since we don’t wish to collect any more inputs from the user, the output context will be left blank.

Video

Can’t I use follow up intents to get the same result?

Yes, you can. In fact, what I have described here is not very different from the way followup intents work under the hood.

But before you use followup intents, read the situations where you cannot use follow up intents.

And then read why the default context lifespan of 2 (that all followup intents use) is a problem.

And finally, learn the technique I have described here anyway, because you will most likely end up using it once you find that your bot cannot be completely built using followup intents alone.

FREE COURSES

Related Posts

  • Thanks, how could we got entity “name” from the first intent and use it in response in last intent? in other words, how to move entity values from one intent to another?
    Best Regards.

  • Hi,

    I have 2 intents. “Category” and “Licensing”. In the first intent Category, it will prompt enter “Licensing”, “Sales”, “Tech-Support”. I entered “Licensing”. User prompted saying, “you will be redirected to Licensing soon..” . How I can redirect to “Licensing” intent without user intervention?

    Thanks,
    Anil

  • Great! Thanks for sharing knowledge. What about if my first intent it is using the main console and my second intent it is working with fullfilment, how can I jump in to that?