Created
December 6, 2018 12:14
-
-
Save myke11j/a0af86183382c09f90fbf7e3890c0105 to your computer and use it in GitHub Desktop.
Lambda Function for Alexa Skill for Account Link card
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 Alexa = require('alexa-sdk'); | |
const APP_ID = process.env.ALEXA_ID; | |
const messages = { | |
greeting: 'Welcome to Dummy Skill', | |
goodByMsg: 'Goodbye', | |
reprompt: 'Sorry, I wasn\'t able to hear that, can you please repeat it?', | |
help: 'This is a dummy skill for showcasing Account Linking' | |
}; | |
const handlers = { | |
'LaunchRequest': function () { | |
const cardTitle = messages.greeting; | |
let content = messages.greeting; | |
this.emit(':askWithLinkAccountCard', content, messages.reprompt, cardTitle, content, null) | |
}, | |
'AMAZON.StopIntent': function () { | |
const cardTitle= messages.goodByMsg; | |
const content = messages.goodByMsg; | |
this.emit(':tellWithCard', content, cardTitle, content, null) | |
}, | |
'AMAZON.CancelIntent': function () { | |
this.emit('AMAZON.StopIntent'); | |
}, | |
'AMAZON.HelpIntent': function () { | |
const content = messages.help; | |
this.emit(':askWithCard', content, messages.reprompt, content, content, null) | |
}, | |
'Unhandled': function () { | |
this.emit('AMAZON.StopIntent'); | |
} | |
}; | |
exports.handler = function (event, context, callback) { | |
try { | |
const alexa = Alexa.handler(event, context, callback); | |
alexa.registerHandlers(handlers); | |
alexa.appId = APP_ID // APP_ID is your skill id which can be found in the Amazon developer console where you create the skill. | |
alexa.execute(); | |
} catch (error) { | |
console.log(`Error in Skill, ${error}`); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment