I'm using dialogflow api v2, REST version with nodejs. This application is meant to be a middleware serving as a bridge for another application. Below is the code I'm using in my model class:
static async GetIntent(intentName) {
let intentsClient = new dialogflow.IntentsClient();
let intent = await intentsClient.getIntent({ name: intentName, intentView: Dialogflow.IntentView.INTENT_VIEW_FULL });
return intent[0];
}
and this is controller class code:
static async GetIntent(req, res) {
try {
let intent = await Dialogflow.GetIntent(req.params.intentName);
res.json({
intent,
});
} catch (err) {
CustomError.Handle(err, res);
}
}
and this is the router code:
router.get('/getIntent', DialogflowController.GetIntent);
I can see there is some change with your Payload,
Please Try this way,
static async GetIntent(req, res) {
try {
const request = {
name: `projects/${config.project_id}/agent/intents/${config.intent_id}`
}
let intent = await Dialogflow.GetIntent(request);
res.json({
intent,
});
} catch (err) {
CustomError.Handle(err, res);
}
}