-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
29 lines (24 loc) · 927 Bytes
/
app.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
var restify = require('restify');
var builder = require('botbuilder');
// dialogs
var searchStories = require('./dialogs/searchStories.js');
var greetings = require('./dialogs/greetings.js');
// Create bot and add dialogs
var bot = new builder.BotConnectorBot({ appId: process.env.APP_ID || 'AppId', appSecret: process.env.APP_SECRET || 'AppSecret' });
bot.add('/', searchStories);
bot.add('/greetings', greetings);
// Install First Run middleware and dialog
bot.use(function (session, next) {
if (!session.userData.firstRun) {
session.userData.firstRun = true;
session.beginDialog('/greetings');
} else {
session.beginDialog('/');
}
});
// Setup Restify Server
var server = restify.createServer();
server.post('/api/messages', bot.verifyBotFramework(), bot.listen());
server.listen(process.env.PORT || 3978, function () {
console.log('%s listening to %s', server.name, server.url);
});