I'm currently trying to change a specific value of one of my context using webhook response and from what I found, the following should work:
{
"fulfillmentText": ${textToSpeech},
"fulfillmentMessages": [{ "text": { "text": [${text}] } }],
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": ${textToSpeech},
"displayText": ${text}
}
}
],
"suggestions": ${suggestions},
"linkOutSuggestion": {
"destinationName": "Feedback",
"url": ${feedbackURL}
}
}
}
},
"outputContexts": [
{
"name": "projects/${projectID}/agent/sessions/${conversationID}/contexts/${context}",
"lifespanCount": 15,
"parameters": {
"param":"value"
}
}]
}
However, this does nothing to change any parameters specified within that context. Am I doing something incorrectly or is there a better method of changing parameters for an output context using webhook responses?
Just managed to solve the issue.
Instead of trying to create my own output context i just manipulated the values in req.body.queryResult.outputContexts
.
For example:
req.body.queryResult.outputContexts[0].parameters.param="value"
and then sent the response with the original outputContext
{
"fulfillmentText": ${textToSpeech},
"fulfillmentMessages": [{ "text": { "text": [${text}] } }],
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": ${textToSpeech},
"displayText": ${text}
}
}
],
"suggestions": ${suggestions},
"linkOutSuggestion": {
"destinationName": "Feedback",
"url": ${feedbackURL}
}
}
}
},
"outputContexts": ${req.body.queryResult.outputContexts}
}