-
-
Save edm00se/21702cdba32200001a6e3884b759415d to your computer and use it in GitHub Desktop.
Hello Alexa blog post code snippets
This file contains 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'; | |
const Alexa = require('alexa-sdk'); | |
// this exported handler is what defines how the Alexa runtime can interact with our module | |
exports.handler = function(event, context, callback) { | |
const alexa = Alexa.handler(event, context); // a new instance | |
alexa.registerHandlers(handlers); // registers handlers (below) | |
alexa.execute(); // now it's ready | |
}; | |
// we'll populate these shortly | |
const handlers = {} |
This file contains 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
const handlers = { | |
'LaunchRequest': function () { // just opening the skill | |
this.emit('AMAZON.HelpIntent'); | |
}, | |
'HelloWorldIntent': function () { // the main intent | |
this.response.speak('Hello World!'); | |
this.emit(':responseReady'); | |
}, // now begin wiring of canned intents | |
'AMAZON.HelpIntent': function () { | |
const speechOutput = 'This is the Hello World Sample Skill.'; | |
const reprompt = 'Say hello, to hear me speak.'; | |
this.response.speak(speechOutput).listen(reprompt); | |
this.emit(':responseReady'); | |
}, | |
'AMAZON.CancelIntent': function () { | |
this.response.speak('Goodbye!'); | |
this.emit(':responseReady'); | |
}, | |
'AMAZON.StopIntent': function () { | |
this.response.speak('See you later!'); | |
this.emit(':responseReady'); | |
}, | |
'Unhandled': function () { | |
this.emit('AMAZON.HelpIntent'); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment