-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbot.js
More file actions
39 lines (31 loc) · 1.12 KB
/
bot.js
File metadata and controls
39 lines (31 loc) · 1.12 KB
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
var yowl = require('yowl');
var bot = yowl();
bot.name = "Pizza Bot";
var local = require('yowl-platform-cli');
bot.extend(local);
var classifier = require('yowl-classifier-bayes');
var training = require('./training');
bot.use(classifier({ training: training }));
bot.use(function(context, event) {
return context.classification == "pizza_stats";
}, function(context, event, next) {
var message = "You have ordered 10 pizzas totaling $100.";
event.send(message, next.unroll);
});
bot.use(function(context, event) {
return context.classification == "make_order";
}, function(context, event, next) {
var message = "Alright, I'll get to work making your pizza.";
event.send(message, next.unroll);
});
bot.use(function(context, event) {
return context.classification == "order_status";
}, function(context, event, next) {
var message = "Your order is on it's way.";
event.send(message, next.unroll);
});
bot.use(function(context, event, next) {
var message = "I'm sorry, I didn't understand your request. I only know things about pizza.";
event.send(message, next);
});
bot.run();