简体   繁体   English

无法在 dialogflow rest api v2 中获取意图详细信息

[英]Unable to get intent details in dialogflow rest api v2

I'm using dialogflow api v2, REST version with nodejs.我正在使用带有 nodejs 的 dialogflow api v2,REST 版本。 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);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM