const SKILL_NAME = ‘SKILL_NAME ‘;
const GET_FACT_MESSAGE = ‘Here\’s your information: ‘;
const HELP_MESSAGE = ‘You can say tell me a fact, or, tell me about something… What can I help you with?’;
const HELP_REPROMPT = ‘What can I help you with?’;
const STOP_MESSAGE = ‘Goodbye!’;
const data = [
‘Fact Number One.’,
‘Fact Number Two.’
];
const GetNewFactHandler = {
canHandle(handlerInput) {
const request = handlerInput.requestEnvelope.request;
return request.type === ‘LaunchRequest’
|| (request.type === ‘IntentRequest’
&& request.intent.name === ‘GetNewFactIntent’);
},
handle(handlerInput) {
const factArr = data;
const factIndex = Math.floor(Math.random() * factArr.length);
const randomFact = factArr[factIndex];
const speechOutput = GET_FACT_MESSAGE + randomFact;
return handlerInput.responseBuilder
.speak(speechOutput)
.withSimpleCard(SKILL_NAME, randomFact)
.getResponse();
},
};