Skip to content

Instantly share code, notes, and snippets.

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;
{
"facts" :[
{
"text" : "Fact1"
},
{
"text" : "Fact2"
},
{
"text" : "Fact3"
const HelloWorldIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'HelloWorldIntent';
},
handle(handlerInput) {
const speakOutput = 'Hello there! If you want to hear facts regarding Windows, say Facts.';
return handlerInput.responseBuilder
.speak(speakOutput)
//.reprompt('add a reprompt if you want to keep the session open for the user to respond')