Created
September 28, 2017 23:26
-
-
Save gotchahn/d83bb256dcc7c6f2d459a65a1db8b004 to your computer and use it in GitHub Desktop.
Alexa Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
// Include the Alexa SDK | |
var Alexa = require("alexa-sdk"); | |
// The handlers object tells Alexa how to handle various actions | |
var handlers = { | |
//Our skill will receive a LaunchRequest when the user invokes the skill with the invocation name, but does not provide any command mapping to an intent. For example, open codecademy | |
"LaunchRequest": function () { | |
this.emit(":tell", "Welcome to Codecademy"); // Create speech output. This is what Alexa will speak back when the user says "Open code academy" | |
}, | |
"HelloIntent": function () { | |
this.emit(":tell", "Hello, Codecademy"); // Calls the SayWelcomeMessage handler. This is what Alexa will speak back when the user says "Ask code academy to say hello" | |
}, | |
"myFavoriteLanguageIntent": function(){ | |
var activity = this.event.request.intent.slots.activity.value; | |
console.log("Activity: "+activity); | |
if(activity == 'book'){ | |
this.emit(":tell", "Hello, Carlos, it is Harry Potter"); | |
} | |
else if(activity == 'language'){ | |
this.emit(":tell", "Hello, Carlos, it is Spanish"); | |
} | |
else if(activity == 'movie'){ | |
this.emit(":tell", "Hello, Carlos, it is La vita e Bella"); | |
} | |
else{ | |
this.emit(":tell", "I don't know, Carlos, maybe have fun with Lorraine?"); | |
} | |
} | |
}; | |
// This is the function that AWS Lambda calls every time Alexa uses your skill. | |
exports.handler = function(event, context, callback) { | |
// Create an instance of the Alexa library and pass it the requested command. | |
var alexa = Alexa.handler(event, context); | |
// Give our Alexa instance instructions for handling commands and execute the request. | |
alexa.registerHandlers(handlers); | |
alexa.execute(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment