forked from TanKucukhas/Cookbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (33 loc) · 1.2 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
// This is a sample skill called State Pop
// It expects to receive a StateRequestIntent with a slot value called usstate.
//
var Alexa = require('alexa-sdk');
var MymockGet = require("../mockGet.js"); // adjust to match your project folder structure
exports.handler = function(event, context, callback){
var alexa = Alexa.handler(event, context);
alexa.registerHandlers(handlers);
alexa.execute();
};
var handlers = {
'LaunchRequest': function () {
var say = 'Welcome!';
this.emit(':ask', say, 'try again');
},
'StateRequestIntent': function() {
var myState = this.event.request.intent.slots.usstate.value;
var say = 'You asked for ' + myState;
MymockGet.mockGet(myState, myResult => {
console.log("sent : " + myState);
console.log("received : " + myResult);
say = say + " and the population is " + myResult;
this.emit(':ask', say, 'try again');
}
);
},
'AMAZON.HelpIntent': function () {
this.emit(':ask', 'Say the name of a U.S. State.', 'try again');
},
'AMAZON.StopIntent': function () {
this.emit(':tell', 'Goodbye!');
}
}