alexa-samples/skill-sample-nodejs-fact

AMAZON.RepeatIntent

Closed this issue · 2 comments

I've been looking for two days and I am not able to find ANYTHING that outlines how to code the AMAZON.RepeatIntent in the fact skill :/ I know you have to add a session attribute, but I'm not sure where to that. I'm assuming somewhere in the GetNewFactHandler?

Is there anything else that needs to be done besides updating these two handlers? Anything with keeping the session open?

Thanks so much.

const GetNewFactHandler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === 'LaunchRequest'
|| (request.type === 'IntentRequest'
&& request.intent.name === 'GetNewFactIntent');
},
handle(handlerInput) {
const requestAttributes = handlerInput.attributesManager.getRequestAttributes();
const randomFact = requestAttributes.t('FACTS');
const speakOutput = requestAttributes.t('GET_FACT_MESSAGE') + randomFact;

return handlerInput.responseBuilder
  .speak(speakOutput)
  // Uncomment the next line if you want to keep the session open so you can
  // ask for another fact without first re-opening the skill
  // .reprompt(requestAttributes.t('HELP_REPROMPT'))
  .withSimpleCard(requestAttributes.t('SKILL_NAME'), randomFact)
  .getResponse();

},
};

const RepeatIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest' && Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.RepeatIntent';
},
handle(handlerInput) {
const sessionAttributes =
handlerInput.attributesManager.getSessionAttributes();
const { lastResponse } = sessionAttributes;
const speakOutput = lastResponse;

return handlerInput.responseBuilder
.speak(speakOutput)
.reprompt(speakOutput)
.getResponse();
}
};

I've been looking for two days and I am not able to find ANYTHING that outlines how to code the AMAZON.RepeatIntent in the fact skill :/ I know you have to add a session attribute, but I'm not sure where to that. I'm assuming somewhere in the GetNewFactHandler?

Is there anything else that needs to be done besides updating these two handlers? Anything with keeping the session open?

Thanks so much.

const GetNewFactHandler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === 'LaunchRequest'
|| (request.type === 'IntentRequest'
&& request.intent.name === 'GetNewFactIntent');
},
handle(handlerInput) {
const requestAttributes = handlerInput.attributesManager.getRequestAttributes();
const randomFact = requestAttributes.t('FACTS');
const speakOutput = requestAttributes.t('GET_FACT_MESSAGE') + randomFact;

return handlerInput.responseBuilder
  .speak(speakOutput)
  // Uncomment the next line if you want to keep the session open so you can
  // ask for another fact without first re-opening the skill
  // .reprompt(requestAttributes.t('HELP_REPROMPT'))
  .withSimpleCard(requestAttributes.t('SKILL_NAME'), randomFact)
  .getResponse();

},
};

const RepeatIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest' && Alexa.getIntentName(handlerInput.requestEnvelope) === 'AMAZON.RepeatIntent';
},
handle(handlerInput) {
const sessionAttributes =
handlerInput.attributesManager.getSessionAttributes();
const { lastResponse } = sessionAttributes;
const speakOutput = lastResponse;

return handlerInput.responseBuilder
.speak(speakOutput)
.reprompt(speakOutput)
.getResponse();
}
};

kweekhant4545@gmail.com