-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example3.Step3.js
65 lines (57 loc) · 2.06 KB
/
Example3.Step3.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
"use strict";
var Alexa = require("alexa-sdk");
var handlers = {
"LaunchRequest": function () {
//We will update this to prompt the user for a name.
if (!this.attributes['username']) {
this.response.speak("Welcome to the HASTAC Conference skill. What is your name?").listen("What should I call you?");
}
else {
this.response.speak("Welcome back " + this.attributes['username'] + ", to the HASTAC Conference skill.");
}
this.emit(':responseReady');
},
"HelloHASTACIntent": function () {
this.response.speak("Hello there.");
this.emit(':responseReady');
},
"LocationHASTACIntent": function () {
if (this.event.request.intent.slots.location.value == "cafeteria"){
this.response.speak("Knightros is located behind the CFE Arena. You can find the arena at H3 or G4 on the maps around campus.");
this.emit(':responseReady');
}
else if (this.event.request.intent.slots.location.value == "student union"){
this.response.speak("The student union is located at the middle of campus.");
this.emit(':responseReady');
}
else {
this.response.speak("What are you trying to find?").listen("Sorry, what are you looking for?");
this.emit(':responseReady');
}
},
//New function for "my name is {name}" and "call me {name}"
"HASTACUserName": function () {
this.attributes['username'] = this.event.request.intent.slots.name.value;
var username = this.attributes['username'];
this.response.speak('Hello ' + username + '!');
this.emit(':responseReady');
},
'AMAZON.StopIntent': function() {
this.response.speak('Goodbye!');
this.emit(':responseReady');
},
'AMAZON.CancelIntent': function() {
this.response.speak('Goodbye!');
this.emit(':responseReady');
},
'SessionEndedRequest': function() {
this.emit(':saveState', true);
}
}
exports.handler = function(event, context, callback){
var alexa = Alexa.handler(event, context);
//Add the database here, and change the permissions for your role.
alexa.dynamoDBTableName = 'HASTACConference';
alexa.registerHandlers(handlers);
alexa.execute();
}