Skip to content

Instantly share code, notes, and snippets.

@Markkop
Last active January 14, 2022 18:11
Show Gist options
  • Select an option

  • Save Markkop/7071ce827d28c059b4ea2a0a21062ab1 to your computer and use it in GitHub Desktop.

Select an option

Save Markkop/7071ce827d28c059b4ea2a0a21062ab1 to your computer and use it in GitHub Desktop.
canHandle example with ask-sdk-core helpers
import { HandlerInput, getRequestType, getIntentName } from 'ask-sdk-core';
const PlayStreamRequestTypes = ['LaunchRequest', 'IntentRequest'];
const PlayStreamRequestIntentNames = [
'PlayStreamIntent',
'AMAZON.ResumeIntent',
'AMAZON.LoopOnIntent',
'AMAZON.NextIntent',
'AMAZON.PreviousIntent',
'AMAZON.RepeatIntent',
'AMAZON.ShuffleOnIntent',
'AMAZON.StartOverIntent',
];
const IntentHandler = {
canHandle(handlerInput: HandlerInput) {
return PlayStreamRequestTypes.some((type) => type === getRequestType(handlerInput.requestEnvelope))
&& PlayStreamRequestIntentNames.some((name) => name === getIntentName(handlerInput.requestEnvelope));
},
//...
}
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment