-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
pickfruit.js
40 lines (35 loc) · 1.17 KB
/
pickfruit.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
//
// Example of using a dictionary to allow the user to choose from a pre-selected list of values in a custom slot type.
//
var chatskills = require('./lib/chatskills');
// Create a new skill.
var pickFruit = chatskills.add('pickfruit');
pickFruit.dictionary = { "fruits": [ 'banana', 'orange', 'apple' ] };
pickFruit.intent('run', {
"slots": {},
"utterances": ["{to|} {run|start|go|launch}"]
}, function(req, res) {
var prompt = "Select a fruit: banana, orange, apple.";
res.say(prompt).reprompt(prompt).shouldEndSession(false);
}
);
// Using the Custom Slot Type "FruitType", with values from a dictionary.
pickFruit.intent('fruit',{
"slots":{"FruitType":"FRUITTYPE"}
,"utterances":["I choose {fruits|FruitType}",
"{fruits|FruitType}"]
},
function(req,res) {
res.say("You selected " + req.slot('FruitType') + '!');
res.shouldEndSession(true);
}
);
pickFruit.intent('*', {
'slots': {},
'utterances': [ '{*}' ]
},
function(req, res) {
res.say("I'm sorry, I'm not familiar with that fruit. Please pick a fruit: banana, orange, apple.");
return true;
}
);