-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjoybot.js
More file actions
64 lines (56 loc) · 2.17 KB
/
Copy pathjoybot.js
File metadata and controls
64 lines (56 loc) · 2.17 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//sets up instansce of botkit
var Botkit = require('../lib/Botkit.js');
if (!process.env.token) {
console.log('Error: Specify token in environment');
process.exit(1);
}
var controller = Botkit.slackbot({
debug: false
});
controller.spawn({
token: process.env.token
}).startRTM(function(err) {
if (err) {
console.log("Couldn't connect to the RTM API");
throw new Error(err);
}
});
//most people always say this to a bot
controller.hears(['hello', 'hi',], ['direct_message','direct_mention','mention'], function(bot, message) {
bot.reply(message, 'hello');
})
controller.hears(['feedme', 'i am hungry', "what's for lunch", "what is for lunch", "what's for dinner", "what is for dinner"], ['direct_message','direct_mention','mention', 'ambient'], function(bot, message) {
bot.startConversation(message,getFood);
})
//used to intiate pick of or delivery
var getFood = function(response,convo) {
convo.ask("Pick up or delivery?", function(response, convo) {
/*if(getFood === "Pickup") {
convo.say("What size of a radius");*/
convo.say('Your input was received');
typeOfCuisne(response, convo);
convo.next();
});
} //typeOFCuisine will eventually be used in either yelp api or delivery api as a parameter
var typeOfCuisne = function(response,convo) {
convo.ask('What type of cuisine are you in the mood for', function(response, convo) {
convo.say('Good choice');
responseGetFood(response, convo);
convo.next();
});
}
//will eventually have to be trigger when a pick up or delivery order has been placed
var responseGetFood = function(response, convo) {
convo.ask("We will place your order, cash or card on file", function(response, convo) {
convo.say('EnJoy!!!');
orderConfirmtion(response, convo);
convo.next();
});
}
//will eventually have to be trigger when a pick up or delivery order has been placed
var orderConfirmtion = function(response, convo) {
convo.ask('is there anything else you need?', function(response, convo) {
convo.say('Speak to you soon');
convo.next();
});
}