Skip to content

Instantly share code, notes, and snippets.

@sebsto
Created January 20, 2019 13:37
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 sebsto/ead49a6d695b9f8a747c10651c3e6904 to your computer and use it in GitHub Desktop.
Save sebsto/ead49a6d695b9f8a747c10651c3e6904 to your computer and use it in GitHub Desktop.
example alexa skill handler
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