I am reading the official documentation from this link: https://cloud.google.com/dialogflow-enterprise/docs/reference/rest/v2beta1/QueryParameters but I am unable to pass a context parameter into my request using the following code:
var query = req.body.query;
const request = {
session: sessionPath,
queryInput: {
text: {
text: query,
languageCode: 'en-US',
},
},
queryParameters: {
contexts: ['Question-followup']
},
};
// Send request and log result
sessionClient
.detectIntent(request)
.then(responses => {
const result = responses[0].queryResult;
console.log(result);
res.json(result);
if (result.intent) {
console.log(` Intent: ${result.intent.displayName}`);
} else {
console.log(` No intent matchede.`);
}
})
.catch(err => {
console.error('ERROR:', err);
});
In the documentation it says that I should have something like:
"contexts": [
{
object(Context)
}
],
The reason I want this is that sometimes DialogFlow is not able to detect the Intent so I would think that by passing the context into the parameter would help dialogflow to find the correct intent!
The contexts
array needs to be an array of Context objects, not just a string with the context names.
The context object looks something like
{
"name": "projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context Name>",
"lifespanCount": 1,
"parameters": {
"anyParameterName": "parameterValue"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With