-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.js
49 lines (43 loc) · 2.1 KB
/
start.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
// Your code, that will be handle the processing of your skill
// The names need to match your Alexa Intents you made in the Skill Builder
const handlers = {
'Positive': function() {
this.emit(':tell', 'Yay! I\'m glad you like programming club!');
},
'Negative': function() {
this.emit(':tell', 'Aww. Programming can be so fun though - you can create apps like me!');
},
// LaunchRequest is special: it is called when your app is opened without an intent for example:
// "Alexa open <skill name>"
'LaunchRequest': function() {
this.emit(':ask', 'Hi there, do you think programming club is good or bad?');
},
// AMAZON.HelpIntent, AMAZON.CancelIntent and AMAZON.StopIntent are built in intents
// They recognise "Help", "Cancel" and "Stop" respectively.
'AMAZON.HelpIntent': function() {
this.emit(':tell', 'You can tell this skill whether you like or don\'t like programming club.');
},
'AMAZON.CancelIntent': function() {
// This means run the 'StopIntent' code instead, as it'll be the same
this.emit('AMAZON.StopIntent');
},
'AMAZON.StopIntent': function() {
// An interjection is a way of making a skill more interesting. It'll put more emphasis on the word
// and you know for sure it'll sound ok with the computer voice. See the range of speechcons at:
// https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speechcon-reference-uk
this.emit(':tell', '<say-as interpret-as="interjection">cheerio</say-as>');
},
// Unhandled is called when your skill doesn't understand what the user was trying to say.
'Unhandled': function() {
this.emit(':ask', 'Sorry, I didn\'t get that. Please can you repeat it?');
}
};
// NOTE: It's unlikely you'll need to edit the code below; you can probably just ignore it
// Get the Alexa SDK
const Alexa = require('alexa-sdk');
// Attach handlers and execute skill logic
exports.handler = function(event, context) {
const alexa = Alexa.handler(event, context);
alexa.registerHandlers(handlers);
alexa.execute();
};