Last active
January 14, 2022 18:11
-
-
Save Markkop/7071ce827d28c059b4ea2a0a21062ab1 to your computer and use it in GitHub Desktop.
canHandle example with ask-sdk-core helpers
This file contains hidden or 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
| 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