Last active
June 21, 2018 22:31
-
-
Save shavo007/a89d82975c9a5420307f0bc7c871b7da 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
'use strict'; | |
var Alexa = require('alexa-sdk'); | |
var Client = require('node-rest-client').Client; | |
var APP_ID = undefined; //OPTIONAL: replace with "amzn1.echo-sdk-ams.app.[your-unique-value-here]"; | |
exports.handler = function(event, context, callback) { | |
var alexa = Alexa.handler(event, context); | |
alexa.APP_ID = APP_ID; | |
var locale = event.request.locale | |
console.log(event) | |
if (locale == 'en-GB'){ | |
alexa.registerHandlers(UKhandlers); | |
} else if (locale == 'de-DE') { | |
alexa.registerHandlers(DEhandlers); | |
} | |
else if (locale == 'en-AU') { | |
alexa.registerHandlers(AUhandlers); | |
} | |
else { | |
alexa.registerHandlers(UShandlers); | |
} | |
alexa.execute(); | |
}; | |
function getStatus(callback) { | |
console.log('get github status'); | |
var client = new Client(); | |
client.get("https://status.github.com/api/status.json", function (data, response) { | |
// parsed response body as js object | |
console.log(data); | |
callback(data); | |
}).on('error', function (err) { | |
console.log('something went wrong on the request', err.request.options); | |
}); | |
} | |
var UShandlers = { | |
'BookingTimeIntent': function () { | |
var date = this.event.request.intent.slots.date.value | |
var time = this.event.request.intent.slots.time.value | |
//TODO need a callback | |
var data = getStatus(); | |
var speechOutput = "Confirming booking. This may take a few seconds"; | |
this.emit(':tell', speechOutput); | |
}, | |
'AMAZON.CancelIntent': function () { | |
//TODO cancel the booking | |
this.emit(':tell', 'Goodbye!'); | |
}, | |
'AMAZON.StopIntent': function () { | |
this.emit(':tell', 'Goodbye!'); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment