如何在api.ai中使用后端Node.js的网页钩子来填充插槽,您能告诉我们这个过程吗?下面是创建样例web钩子的示例响应。
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"
});发布于 2017-10-09 13:53:04
最后,我得到了答案,首先我们需要启用称为域的选项,这个选项在履行选项卡中是可用的,因为我们需要将所有域的启用Web钩子更改为。下面是使用Node.js API的示例响应,使用此响应,我将响应api.ai控制台。如果有人有疑问,请发@这里,谢谢。
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'
});
});https://stackoverflow.com/questions/45317948
复制相似问题