Created
March 21, 2016 22:58
-
-
Save joshskeen/16527f1b2f2a9cbf0848 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.intent('airportinfo', { | |
'slots': { | |
'AIRPORTCODE': 'FAACODES' | |
}, | |
'utterances': ['{|flight|airport} {|delay|status} {|info} {|for} {-|AIRPORTCODE}'] | |
}, | |
function(req, res) { | |
//get the slot | |
var airportCode = req.slot('AIRPORTCODE'); | |
var reprompt = 'Tell me an airport code to get delay information.'; | |
if (_.isEmpty(airportCode)) { | |
var prompt = 'I didn\'t hear an airport code. Tell me an airport code.'; | |
res.say(prompt).reprompt(reprompt).shouldEndSession(false); | |
return true; | |
} else { | |
var faaHelper = new FAADataHelper(); | |
faaHelper.requestAirportStatus(airportCode).then(function(airportStatus) { | |
console.log(airportStatus); | |
res.say(faaHelper.formatAirportStatus(airportStatus)).send(); | |
}).catch(function(err) { | |
console.log(err.statusCode); | |
var prompt = 'I didn\'t have data for an airport code of ' + airportCode; | |
res.say(prompt).reprompt(reprompt).shouldEndSession(false).send(); | |
}); | |
return false; | |
} | |
} | |
); | |
//hack to support custom utterances in utterance expansion string | |
console.log(app.utterances().replace(/\{\-\|/g, '{')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment