-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
44 lines (42 loc) · 1.08 KB
/
index.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
const FlowBot = require('flow-bot').FlowBot;
const restify = require('restify');
const inquirer = require('inquirer');
var choices = [
'hello-ConsoleConnector',
'hello-ChatConnector',
'basics-waterfall',
'basics-loops',
'basics-menus',
'basics-naturalLanguage',
'basics-firstRun',
'basics-logging'
];
inquirer.prompt([
{
type: 'list',
name: 'bot',
message: 'Choose a bot to be executed:',
paginated: true,
choices: choices
}
]).then(function (answers) {
if (answers.bot === 'hello-ConsoleConnector') {
var opts = {
consoleConnector: true,
botPath: './bots/hello-ChatConnector'
}
new FlowBot(opts);
} else {
var opts = {
botPath: './bots/'+answers.bot
};
var server = restify.createServer();
server.bot = new FlowBot(opts, function() {
var port = process.env.port || process.env.PORT || 3978;
server.listen(port, function () {
server.post('/api/messages', server.bot.connector.listen());
console.log('botBrunning in http://localhost:'+ port +'/api/messages');
});
});
}
});