-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
55 lines (49 loc) · 1.26 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
var alexa = require('alexa-app'),
ssml = require('ssml'),
QS = require("querystring"),
Pandorabot = require('pb-node'),
config = require('config');
var pboptions = {
url: config.get('Pb.url'),
app_id: config.get('Pb.app_id'),
user_key: config.get('Pb.user_key'),
botname: config.get('Pb.botname'),
}
var bot = new Pandorabot(pboptions);
var app = new alexa.app();
/**
* LaunchRequest.
*/
app.launch(function(request,response) {
response.say('Hey there fancy pants!');
response.card("Hey there fancy pants!","This is an example card");
});
/**
* IntentRequest.
*/
app.intent('phrase',
{
'slots' : {'phrase': 'LITERAL'},
'utterances': ['{How is your day going?|Hello|Are you a chatbot?|My name is Michael}']
},
function(request,response) {
var phrase = request.slot('phrase');
var pbdata = QS.stringify({input: phrase});
bot.talk(pbData,function(err,res){
if(!err){
console.log(res);
response.say(res);
response.shouldEndSession(true);
response.send();
}
});
}
);
/**
* Error handler for any thrown errors.
*/
app.error = function(exception, request, response) {
response.say('Sorry, something bad happened');
};
// Connect to lambda
exports.handler = app.lambda();