dialogflow webhook参数无法通过

时间:2018-06-18 11:54:54

标签: javascript dialogflow

'use strict';
var http = require('http');
var request = require('request');
exports.weatherWebhook = (req, res) => {
    const host = 'http://api.openweathermap.org/';
    const wwoApiKey = '7ffbb59524a81a6ac42ac3e942f68c5d';
    var city = req.body.queryResult.parameters['geo-city'];
    var path = 'data/2.5/weather?' +'APPID=' + wwoApiKey +'&q=' +city+'&units=imperial';
    request(host+path,function(error,response,body)
    {   
        var a=JSON.parse(body);
        console.log(JSON.parse(body));
        var temp=a.main.temp;
        var location=a.name;
        console.log(location);
        res.json({ 'fulfillmentText': city }); 
    });


};

为什么我会收到内部服务器错误?如何通过解析功能将值传递给履行文本?

1 个答案:

答案 0 :(得分:1)

这里有很多问题,所以很难知道从哪里开始。

您说您想要使用对话框流的参数,但您还没有包含dialogflow fulfillment library,并且您没有进行任何意图处理,因此它不是&#39清除你在那里遇到麻烦。

当你这样做时,你可能想要use Promises instead of callbacks

最后,如果您遇到错误,那么将错误日志与您的代码一起发布将有助于我们指出正确的方向,而无需自行运行代码。

相关问题