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!