如何使用后端 Node.js 的网络摘要在 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"
});
答案 0 :(得分:2)
最后,我得到了答案,首先我们需要启用名为Domains的选项,该选项在履行选项卡中可用,因为我们需要将选项更改为为所有域启用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'
});
});