Reputation: 377
I have setup a nodeJS server to return responses to a dialogflow webhook. I want to be able to send back a context in the JSON response so that dialogflow logic can move to the next desired Intent in the conversation flow.
In the response payload, I tried inserting "outputContexts" array in order to set the context. However this is not working in this form. The response Json is pasted below. The variable contextName holds the desired value of context to be sent back.
var simpleResponse = {
"payload": {
"google": {
"expectUserResponse": true,
"outputContexts": [
{
"name": "projects/my-agent-v2/agent/sessions/" + sessionId + "/contexts/" + contextName,
"lifespanCount": 1,
"parameters": {
"param": "param value"
}
}
],
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "Simple response",
"displayText": "Simple response"
}
}]}}}};
The control should move to intent = awaiting_more_details. The above returned context is the "input context" to this intent.
I hope this gives an understanding about what I want to achieve.
Upvotes: 0
Views: 1004
Reputation: 3005
Your response has the wrong format, the outputContexts
array must be in the top level object, next to payload
. See Dialogflow's Discovery document for the authoritative specification: https://www.googleapis.com/discovery/v1/apis/dialogflow/v2beta1/rest
Upvotes: 1