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!
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.
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...
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.