Reputation: 733
Let's say my bot has an ongoing conversation with the user and my webhook asks "Are you done?" and the user responds "Yes". How do I close the conversation through the webhook? I suspect it is through followupEventInput but I could not get anything to work.
I am not using a nodeJS library. Coding in C#.
Here is what I tried: I respond with an output context and an event: the event is associated with "End conversation" under the Google Assistant at the bottom of the intent window.
{
"fulfillmentText": "OK. The note was recorded.",
"fulfillmentMessages": [
{
"text": {
"text": [
"OK. The note was recorded."
]
}
}
],
"outputContexts": [
{
"lifespanCount": 2,
"name": "projects/xxx/agent/sessions/1512399774430/contexts/note-end"
}
],
"followupEventInput": {
"name": "end-event",
"languageCode": "en"
}
}
With the above code, the user never hears "OK. The note was recorded.", the session ends abruptly with Google Home saying "The app is not responding anymore" (or something similar). Works but not acceptable.
If I don't put the followupEvent, the user hears "OK. The note was recorded." but the conversation doesn't end... then I need to rely on the user to close it using another intent, which is what I want to avoid as it would be redundant.
Upvotes: 1
Views: 1043
Reputation: 3469
You have two options to end a Google Assistant conversation with Dialogflow:
Go to the intent defined in Dialogflow and scroll down and click on Google Assistant
and check the box labeled End conversation
NOTE: this will only work with responses defined in Dialogflow console, not responses created by fulfillment.
Respond to Dialogflow's webhook request with a response of the form:
{
"fulfillmentMessages": [
{
{
"platform": "ACTIONS_ON_GOOGLE",
"paylaod":{
{
"expectUserResponse": false,
...
}
}
}
}
],
...
}
Using either of these methods your app will say whatever is specified in the console (for #1) or webhook (for #2) and end the conversation with the user. Fill in values in the response section of the Dialogflow intent (for #1) or the payload object (for #2) to send a response to the user as you end the conversation.
Sources
Dialogflow Webhook Response v2 docs:https://dialogflow.com/docs/reference/api-v2/rest/v2beta1/WebhookResponse
Action on Google webhook response docs: https://developers.google.com/actions/reference/rest/Shared.Types/AppResponse#FIELDS.expect_user_response
Upvotes: 1
Reputation: 733
OK. After further investigation, it seems that:
Upvotes: 0