【问题标题】:Unable to get intent details in dialogflow rest api v2无法在 dialogflow rest api v2 中获取意图详细信息
【发布时间】:2021-03-28 22:38:34
【问题描述】:

我正在使用 dialogflow api v2,带有 nodejs 的 REST 版本。此应用程序旨在成为一个中间件,充当另一个应用程序的桥梁。下面是我在模型类中使用的代码:

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];
    }

这是控制器类代码:

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);

【问题讨论】:

    标签: node.js rest express dialogflow-es


    【解决方案1】:

    我可以看到您的有效负载发生了一些变化,

    请尝试这种方式,

    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 之前确保您发送的是什么。它必须具有我上面提到的格式。我已经测试过了,它的工作原理
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-26
    • 1970-01-01
    • 2020-07-21
    • 1970-01-01
    相关资源
    最近更新 更多