Skip to content

Instantly share code, notes, and snippets.

@edm00se

edm00se/begin.js Secret

Created May 23, 2018 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edm00se/21702cdba32200001a6e3884b759415d to your computer and use it in GitHub Desktop.
Save edm00se/21702cdba32200001a6e3884b759415d to your computer and use it in GitHub Desktop.
Hello Alexa blog post code snippets
'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 = {}
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