Dialogflow-fulfillment-nodejs: agent.setFollowupEvent purges agent.add

Created on 20 Jul 2018  路  11Comments  路  Source: dialogflow/dialogflow-fulfillment-nodejs

I'm trying to make my bot say some stuff and later trigger an Intent with an Event trigger. But, every time I have something like:

agent.add('I will say something here!');
agent.setFollowupEvent('SOME_EVENT');

The agent.add command is skipped over and the bot goes directly to the intent triggered by SOME_EVENT.

If I remove the line of code with agent.setFollowupEvent, it works fine.

Is this a bug or am I misusing the api?

Cheers!

Most helpful comment

This is not a bug in the library but the way Dialogflow works. Follow up events are a way to redirect from the currently match intent to another intent. The currently matched intent does not have a chance to respond before it is redirected. This means you will only have one response from the intent that is redirected to last. You can't compile response from multiple intent responses by redirecting through multiple intents with follow up events.

When a followup event is triggered from the webhook, the event specified in the webhook response is triggered. Triggering the event through a webhook sends the request back through Dialogflow for matching without responding to the user. The response to the user is sent as if the user triggered the event that was triggered in the webhook. After the second intent is matched by the event, Dialogflow will do any necessary work (like webhook calls or additional prompts for required parameters) and send a response back as if the second intent was the originally matched intent.

enter image description here

  1. A user sends a request to Dialogflow.
  2. "Intent 1" is matched by Dialogflow.
  3. A webhook request is sent to your fulfillment server, which indicates that intent 1 was matched.
  4. Your fulfillment server responds to the webhook request with a followup event response.
  5. Dialogflow re-matches intent 2 based on the followup event sent in the webhook response.
  6. Dialogflow sends a response to the user based solely on intent 2 being matched. Dialogflow may send another webhook call indicating intent 2 was matched, or send a prompt for unfulfilled required parameters (if configured) for intent 2.

All 11 comments

This is not a bug in the library but the way Dialogflow works. Follow up events are a way to redirect from the currently match intent to another intent. The currently matched intent does not have a chance to respond before it is redirected. This means you will only have one response from the intent that is redirected to last. You can't compile response from multiple intent responses by redirecting through multiple intents with follow up events.

When a followup event is triggered from the webhook, the event specified in the webhook response is triggered. Triggering the event through a webhook sends the request back through Dialogflow for matching without responding to the user. The response to the user is sent as if the user triggered the event that was triggered in the webhook. After the second intent is matched by the event, Dialogflow will do any necessary work (like webhook calls or additional prompts for required parameters) and send a response back as if the second intent was the originally matched intent.

enter image description here

  1. A user sends a request to Dialogflow.
  2. "Intent 1" is matched by Dialogflow.
  3. A webhook request is sent to your fulfillment server, which indicates that intent 1 was matched.
  4. Your fulfillment server responds to the webhook request with a followup event response.
  5. Dialogflow re-matches intent 2 based on the followup event sent in the webhook response.
  6. Dialogflow sends a response to the user based solely on intent 2 being matched. Dialogflow may send another webhook call indicating intent 2 was matched, or send a prompt for unfulfilled required parameters (if configured) for intent 2.

Can you provide some sample code for adding a followup event? I tried to generate an event in following ways, I'm not getting any error, but the followup intent is not triggered

agent.setFollowupEvent('CUSTOMER_NAME_REQUESTED');

OR

agent.setFollowupEvent({ "name": "CUSTOMER_NAME_REQUESTED", "parameters" : { "received": "false"}});

Please help

@juliejoseph3 Many of the Dialogflow samples have followup events like here.

Thanks Sarahdwyer.

I did the same in code and created an intent with the event 'CUSTOMER_NAME_REQUESTED', but the followup intent is not getting triggered. Also, No error shown

What could be the reason?

Honestly, it could be a number of things but I think you'll find it very helpful going through the sample to get a better idea of triggering intents in general.

Thankyou!

Is there a way to do setfollowup with agent.add()?

agent.setFollowupEvent({ "name": "CUSTOMER_NAME_REQUESTED", "parameters" : { "received": "false"}});

after two days of the struggle, this works for me. Thanks a lot. You saved me.

@juliejoseph3 Many of the Dialogflow samples have followup events like here.

does that fact that line 71 puts the call to setFollowupEvent inside a variable assignment create a different result than just saying agent.setFollowupEvent('call_transfer_event')? If so, how

Hey, @davidwkaiser did you figure out the reason behind the assignment?

Hey, @davidwkaiser did you figure out the reason behind the assignment?

No, I didn't. I figured out a workaround and kept moving...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mukuljainx picture mukuljainx  路  5Comments

newtonmunene99 picture newtonmunene99  路  3Comments

SiddAjmera picture SiddAjmera  路  8Comments

jzxhuang picture jzxhuang  路  6Comments

santbob picture santbob  路  3Comments