I am following the Wit AI tutorial and I got to a point where I am stuck. I am trying to extend the quick start weather tutorial to call an actual weather API and I am having no luck.
Here is my modified getForecast method. The original can be found here: 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;
});
},
};