-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
72 lines (59 loc) · 1.96 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var Alexa = require('alexa-sdk');
var FACTS = require('./facts');
var APP_ID = 'amzn1.ask.skill.8673f368-ada6-4d8a-bc27-9d2c992dea60';
var SKILL_NAME = 'Autism Fact';
var a = Math.floor(Math.random() * FACTS.length);
function launchRequest() {
console.log('Running LaunchRequest', arguments);
this.emit('GetFact');
}
function getNewFactIntent() {
console.log('Running GetNewFactIntent', arguments);
this.emit('GetFact');
}
function getFact() {
console.log('Running GetFact', arguments);
var randomFact = FACTS[a];
a += 1;
// Create speech output
if (typeof randomFact === 'undefined') {
a = 0;
randomFact = FACTS[a];
a += 1;
}
var speechOutput = 'Here\'s your fact: ' + randomFact + ' Do you want more facts? ';
var reprompt = 'Do you want more facts?';
this.emit(':askWithCard', speechOutput, reprompt, SKILL_NAME, randomFact);
}
function HelpIntent() {
var speechOutput = 'You can say tell me a autism fact, or, you can say exit... What can I help you with?';
var reprompt = 'What can I help you with?';
this.emit(':ask', speechOutput, reprompt);
}
function CancelIntent() {
console.log('Running CancelIntent', arguments);
this.emit(':tell', 'Otsimo is an education app for children who have autism syndrome. We are creating educational games and parent app. Goodbye!');
}
function StopIntent() {
console.log('Running StopIntent ', arguments);
this.emit(':tell', 'Goodbye!');
}
function unhandled() {
var message = 'Say yes to continue, or no to end the game.';
this.emit(':ask', message, message);
}
var handlers = {
LaunchRequest: launchRequest,
GetNewFactIntent: getNewFactIntent,
GetFact: getFact,
'AMAZON.HelpIntent': HelpIntent,
'AMAZON.CancelIntent': CancelIntent,
'AMAZON.StopIntent': StopIntent,
'Unhandled': unhandled
};
exports.handler = function (event, context, callback) {
var alexa = Alexa.handler(event, context, callback);
alexa.appId = APP_ID;
alexa.registerHandlers(handlers);
alexa.execute();
};