-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathfunny.js
57 lines (50 loc) · 1.36 KB
/
funny.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
var chatskills = require('./lib/chatskills');
// Create a new skill.
var funny = chatskills.add('funny');
// Create intents.
funny.intent('knockKnock', {
'slots': {'STATE':'NUMBER'},
'utterances': [ '{to |}{tell|say} {me |} {a |}joke',
'{banana|bannana|banan|bana|bannanna|bannananna} who' ]
},
function(req, res) {
var state = req.get('state') || 0;
if (state < 3) {
req.set('state', state + 1);
res.say('Knock knock.');
}
return true;
}
);
funny.intent('banana', {
'slots': {'STATE':'NUMBER'},
'utterances': [ "{whos|who's|who is} there" ]
},
function(req, res) {
var state = req.get('state');
if (state < 2) {
req.set('state', state + 1);
res.say('Banana.');
}
else if (state == 3) {
req.set('state', state + 1);
res.say('Orange.');
}
return true;
}
);
funny.intent('orange', {
'slots': {'STATE':'NUMBER'},
'utterances': [ "{orange|oronge|arange} who" ]
},
function(req, res) {
if (req.get('state') == 4) {
res.say("Orange you glad I didn't say banana?");
// End session.
return false;
}
else {
return true;
}
}
);