-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
52 lines (46 loc) · 1.53 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"use strict";
//Variables
var Alexa = require('alexa-sdk');
var SKILL_NAME = "Alexa Template";
var APP_ID = "";
//List of compliments
var COMPLIMENT_LIST = [
"Damn son, you're looking mighty fine today!",
"Wow! You made an Alexa skill. You're smarter than I thought!",
"If you were a food, you'd be an endless supply of CheeseCake"
];
// Core handler - error
exports.handler = function(event, context, callback){
var alexa = Alexa.handler(event, context);
alexa.APP_ID = APP_ID;
alexa.registerHandlers(handlers);
alexa.execute();
}
//Handlers to manage the requests
var handlers = {
'LaunchRequest': function(){
this.emit('GetCompliment');
},
'GetComplimentIntent': function() {
this.emit('GetCompliment');
},
'GetCompliment': function(){
var complimentIndex = Math.floor(Math.random() * COMPLIMENT_LIST.length);
var randomCompliment = COMPLIMENT_LIST[complimentIndex];
//Output
var speechOutput = "Your compliment " + randomCompliment;
this.emit(":tellWithCard", speechOutput, SKILL_NAME, randomCompliment);
},
// Alexa Defalut Intents
'AMAZON.HelpIntent': function(){
var speechOutput = "You can say give me a compliment or you can say exit..";
var reprompt = "What can I help you with ?";
this.emit(":ask", speechOutput, reprompt);
},
'AMAZON.StopIntent': function(){
this.emit(":tell", "Good Bye!");
},
'AMAZON.CancelIntent': function(){
this.emit(":tell", "Good Bye!");
}
}