无法在 dialogflow rest api v2 中获取意图详细信息
Unable to get intent details in dialogflow rest api v2
我正在使用 dialogflow api v2,带有 nodejs 的 REST 版本。此应用程序旨在成为一个中间件,充当另一个应用程序的桥梁。下面是我在模型中使用的代码 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];
}
这是控制器 class 代码:
static async GetIntent(req, res) {
try {
let intent = await Dialogflow.GetIntent(req.params.intentName);
res.json({
intent,
});
} catch (err) {
CustomError.Handle(err, res);
}
}
这是路由器代码:
router.get('/getIntent', DialogflowController.GetIntent);
我可以看到您的有效载荷有一些变化,
请尝试这种方式,
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);
}
}
我正在使用 dialogflow api v2,带有 nodejs 的 REST 版本。此应用程序旨在成为一个中间件,充当另一个应用程序的桥梁。下面是我在模型中使用的代码 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];
}
这是控制器 class 代码:
static async GetIntent(req, res) {
try {
let intent = await Dialogflow.GetIntent(req.params.intentName);
res.json({
intent,
});
} catch (err) {
CustomError.Handle(err, res);
}
}
这是路由器代码:
router.get('/getIntent', DialogflowController.GetIntent);
我可以看到您的有效载荷有一些变化,
请尝试这种方式,
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);
}
}