0
위트 AI 튜토리얼을 따르고 있는데, 나는 갇혀있다. 퀵 스타트 날씨 튜토리얼을 확장하여 실제 날씨 API를 호출하려고하고 있으며 운이 없다.위트 (AI) 및 비동기 함수
다음은 수정 된 getForecast 메소드입니다. 원래는 여기에서 찾을 수 있습니다 : https://wit.ai/docs/quickstart
var weather = require('weather-js');
const actions = {
send(request, response) {
const {sessionId, context, entities} = request;
const {text, quickreplies} = response;
console.log('sending...', JSON.stringify(response));
},
getForecast({context, entities}) {
var location = firstEntityValue(entities, 'location');
weather.find({search: location, degreeType: 'F'}, function(err, result) {
if(err){
context.missingLocation = true;
delete context.forecast;
}else{
var temperature = result[0].current.temperature;
context.forecast = temperature+ ' degrees in '+location; // we should call a weather API here
delete context.missingLocation;
fs.writeFile("weather.json",JSON.stringify(result));
}
return context;
});
},
};