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) { // 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) { // launch requests as well as any new session, as games are not saved in progress, which makes // no one shots a reasonable idea except for help, and the welcome message provides some help. return Alexa.isNewSession(handlerInput.requestEnvelope) || Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest'; }
canHandle(handlerInput) { return Alexa.getRequestType(handlerInput.requestEnvelope) === 'SessionEndedRequest'; }
canHandle(handlerInput) { return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest' && Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.HelpIntent'; }
canHandle(handlerInput) { return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest' && (Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.CancelIntent' || Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.StopIntent'); }
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'; }