forked from lykmapipo/majibot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnectorSetup.js
More file actions
33 lines (24 loc) · 1.08 KB
/
connectorSetup.js
File metadata and controls
33 lines (24 loc) · 1.08 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
module.exports = () => {
const restify = require('restify');
global.builder = require('botbuilder');
//If testing via the emulator, no need for appId and appPassword. If publishing, enter appId and appPassword here
const connector = new builder.ChatConnector({
appId: process.env.MICROSOFT_APP_ID ? process.env.MICROSOFT_APP_ID : '',
appPassword: process.env.MICROSOFT_APP_PASSWORD ? process.env.MICROSOFT_APP_PASSWORD : '',
gzipData: true
});
global.bot = new builder.UniversalBot(connector);
global.quickReplies = require('botbuilder-quickreplies');
quickReplies.LocationPrompt.create(bot);
bot.use(quickReplies.QuickRepliesMiddleware);
// Persist userData
bot.set('persistUserData', true);
// Do not persist conversationData
bot.set(`persistConversationData`, true);
// Setup Restify Server
const server = restify.createServer();
server.listen(process.env.PORT || 3978, () => {
console.log('%s listening to %s', server.name, server.url);
});
server.post('/api/messages', connector.listen());
};