Skip to content

Instantly share code, notes, and snippets.

@apoorvlathey
Created April 23, 2020 17:20
Show Gist options
  • Save apoorvlathey/0243d23afc7c0f0ec3b387c85789fadd to your computer and use it in GitHub Desktop.
Save apoorvlathey/0243d23afc7c0f0ec3b387c85789fadd to your computer and use it in GitHub Desktop.
const FactsIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'FactsIntent';
},
handle(handlerInput) {
var random = factsList.facts[Math.floor(Math.random() * factsList.facts.length)]; //select a random fact from json file
var factText = random.text;
var speakOutput = "Did you know that " + factText;
return handlerInput.responseBuilder
.speak(speakOutput)
//.reprompt('add a reprompt if you want to keep the session open for the user to respond')
.getResponse();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment