node.js - 如何使用后端 Node js 在 Api.ai 中制作用于槽填充的 Webhook

标签 node.js dialogflow-es

如何使用后端 Node.js 的 web-hooks 在 api.ai 中进行槽位填充,请您告诉我们该过程。以下是我用于创建示例 Webhook 的示例响应。

 return res.json({
                speech: "here is the sample one.",
                displayText: "here is the sample one ",
                data: {...},
                contextOut: [{"name":"weather", "lifespan":2, "parameters":
                             {"city":"Rome"}}],
                source: "from API"
        });

最佳答案

最后我得到了答案,首先我们需要启用名为“域”的选项,该选项在“履行”选项卡中可用,因为我们需要将选项更改为为所有域启用 Webhook。下面是 Node.js API 的示例响应,我使用此响应来响应 api.ai 控制台。如果有人有疑问,请发帖@Here,谢谢。

const express = require('express');
const bodyParser = require('body-parser');

const restService = express();

restService.use(bodyParser.urlencoded({
    extended: true
}));

restService.use(bodyParser.json());

restService.post('/echo', function(req, res) {
    var speech = req.body.result && req.body.result.parameters && req.body.result.parameters.response1 ? req.body.result.parameters.response2 : "Seems like some problem."

    return res.json({
        speech: speech,
        displayText: speech,
        source: 'webhook-echo-sample'
    });
});

关于node.js - 如何使用后端 Node js 在 Api.ai 中制作用于槽填充的 Webhook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45317948/

相关文章:

php - 兼容性 AES-256-CBC Node/Laravel

actions-on-google - 谷歌操作中基本卡片的新行

dialogflow-es - 如何重置参数值以便代理可以再次请求参数?

firebase - Google DialogFlow V2 履行中出现神秘错误(Google Assistant 模拟器空响应、请求、错误选项卡)

actions-on-google - 是否可以从我自己的 AoG 应用程序的实现中触发另一个 Actions on Google 应用程序?

node.js - 如何在大型 Cassandra 集合中高效查询数据?

node.js - MongoDB - 错误 : document must have an _id before saving

javascript - NodeJS 中的 MySQL 不适用于 INSERT INTO 中的多个语句

node.js - Kubernetes、Docker 和 SSL

python - 使用 Dialogflow Python API 在 Dialogflow 代理内创建知识库的问题