-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
hello.js
37 lines (30 loc) · 886 Bytes
/
hello.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
var chatskills = require('./lib/chatskills');
var readlineSync = require('readline-sync');
// Create a skill.
var hello = chatskills.app('hello');
// Launch method to run at startup.
hello.launch(function(req,res) {
res.say("Ask me to say hi!");
// Keep session open.
res.shouldEndSession(false);
});
// Create an intent.
hello.intent('helloWorld', {
'slots': {},
'utterances': [ '{to |}{say|speak|tell me} {hi|hello|howdy|hi there|hiya|hi ya|hey|hay|heya}' ]
},
function(req, res) {
res.say('Hello, World!');
}
);
// Start running our skill.
chatskills.launch(hello);
// Console client.
var text = ' ';
while (text.length > 0 && text != 'quit') {
text = readlineSync.question('> ');
// Respond to input.
chatskills.respond(text, function(response) {
console.log(response);
});
}