canHandle(handlerInput) { return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest' && (Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.CancelIntent' || Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.StopIntent'); }
canHandle(handlerInput) { // only treat no as an exit when outside a game let isCurrentlyPlaying = false; const { attributesManager } = handlerInput; const sessionAttributes = attributesManager.getSessionAttributes(); if (sessionAttributes.gameState && sessionAttributes.gameState === 'STARTED') { isCurrentlyPlaying = true; } return !isCurrentlyPlaying && Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest' && Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.NoIntent'; }
canHandle(handlerInput) { return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest' && Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.HelpIntent'; }
canHandle(handlerInput) { // handle fallback intent, yes and no when playing a game // for yes and no, will only get here if and not caught by the normal intent handler return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest' && (Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.FallbackIntent' || Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.YesIntent' || Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.NoIntent'); }
canHandle(handlerInput) { // only start a new game if yes is said when not playing a game. let isCurrentlyPlaying = false; const { attributesManager } = handlerInput; const sessionAttributes = attributesManager.getSessionAttributes(); if (sessionAttributes.gameState && sessionAttributes.gameState === 'STARTED') { isCurrentlyPlaying = true; } return !isCurrentlyPlaying && Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest' && Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.YesIntent'; }
canHandle(handlerInput) { // handle numbers only during a game let isCurrentlyPlaying = false; const { attributesManager } = handlerInput; const sessionAttributes = attributesManager.getSessionAttributes(); if (sessionAttributes.gameState && sessionAttributes.gameState === 'STARTED') { isCurrentlyPlaying = true; } return isCurrentlyPlaying && Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest' && Alexa.getIntentName(handlerInput.requestEnvelope) === 'NumberGuessIntent'; }