Home / DialogFlow / Events / Reader Question: Will followup events work when an intent has an input context?
DialogFlow | Events

Reader Question: Will followup events work when an intent has an input context?

I got this question recently on my YouTube channel:

can I have both input context and event & bcoz if input context is provided means the intent doesn’t trigger in middle right

This is a good question. If the intent is being guarded by an input context, can you still invoke the intent using an Event if the context is not active?

Now, there are actually two different possibilities here.

  • You send a followup event from your webhook. The input context of the corresponding intent is not active.
  • You send a followup event from your webhook. The input context of the corresponding intent is active.

When you are trying to find answers for such questions, it is very helpful if you can set up simple tests for this.

And for this, I recommend using Mockable.

Input Context is not active

So I created a quick mock response with the following information:

Notice that the followupEvent it is triggering is simply named “followup”.

Here is the intent which triggers this response. Remember, the intent calls the webhook, and when the webhook responds you should see the Response from a different intent. That is why, in the Response section, I have written “This should not be displayed”.

Let us take a look at what the followup event intent (that is, the intent which has the event called “followup”) looks like. Notice the following:

  • it has an event called “followup”, exactly matching what we have in the response from Mockable
  • it has no training phrases (that is, there isn’t any other way to trigger this intent)

 

Make sure you have set the URL for the Mockable response in your fulfillment.

Let us now test everything inside the Dialogflow simulator:

Everything works as expected. Now it is time to throw a spanner into the works. 🙂

Add an input context to the “followup-event-intent”. I am calling it mycontext.

Now let us try it in the Dialogflow simulator again. This time, the followup-event-intent does not fire, because it is guarded by an input context which isn’t active.

Input Context is Active

Let us now set mycontext as an output context for the triggering intent:

Now let us try the simulator once again. You will see that the followup-event-intent does get triggered this time, because the input context is still active.

Homework for the reader:

Is the input context still active after you see a response in the simulator?

(Hint: Click on Diagnostic Info and verify this for yourself).

Summary

The followup event (as well as regular Event) can only fire if the input context of that intent is also active.

Related Posts