Created
January 20, 2019 13:37
-
-
Save sebsto/ead49a6d695b9f8a747c10651c3e6904 to your computer and use it in GitHub Desktop.
example alexa skill handler
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 HelloWorldIntentHandler = { | |
canHandle(handlerInput) { | |
return handlerInput.requestEnvelope.request.type === 'IntentRequest' && handlerInput.requestEnvelope.request.intent.name === 'HelloWorldIntent'; | |
}, | |
async handle(handlerInput) { | |
const { | |
accessToken | |
} = handlerInput.requestEnvelope.context.System.user; | |
let speechText = ''; | |
if (!accessToken) { | |
speechText = 'You must authenticate with your Amazon Account to use this skill. I sent instructions for how to do this in your Alexa App'; | |
return handlerInput.responseBuilder.speak(speechText).withLinkAccountCard().getResponse(); | |
} else { | |
speechText = 'Hello World!'; | |
return handlerInput.responseBuilder.speak(speechText).getResponse(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment