【发布时间】:2017-03-16 00:22:46
【问题描述】:
我试图让基本的 node.js webhook echo 示例在 heroku 上工作。但是我不断收到 206 错误。我听说这可能来自 heroku 所做的重定向或来自不完整的 json。这里有什么帮助吗?
我还在 api.ai 上附上了我的意图截图
我在使用 yahoo 天气示例 python 应用程序时遇到了同样的错误,所以我不确定发生了什么,因为这都是 api.ai 配置。
我也在这里问过这个问题https://discuss.api.ai/t/webhook-issue-error-206/4535/4
我的代码如下,我是node.js的新手,有什么问题吗?我在其 JSON 中添加了我认为 api.ai 需要的字段。
app.post('/hook', function(req, res) {
console.log('hook request');
try {
var speech = 'empty';
if (req.body) {
if (req.body.result) {
speech = '';
if (req.body.result.fulfillment) {
speech += req.body.result.fulfillment.speech;
speech += ' ';
}
if (req.body.result.action) {
speech += 'action: ' + req.body.result.action;
}
}
}
console.log('result: ', speech);
return res.json({
speech: speech,
displayText: speech,
data: [],
contextOut: [],
source: 'yahooweather'
});
【问题讨论】:
-
这是当 api.ai 尝试访问它时 papertrail 在我的 heroku 服务器上所说的:
at=info method=POST path="/" host=car-status.herokuapp.com request_id=b08633f7-33ab-45f3-9493-91be258a2b52 fwd="54.157.251.180" dyno=web.1 connect=0ms service=25ms status=404 bytes=376 protocol=https
标签: node.js google-home api-ai