-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathapp.ts
More file actions
26 lines (22 loc) · 839 Bytes
/
Copy pathapp.ts
File metadata and controls
26 lines (22 loc) · 839 Bytes
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
import { Bot, TestAdapter } from 'botbuilder';
import { BotFrameworkAdapter } from 'botbuilder-services';
import * as restify from 'restify';
// Create server
let server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
console.log(`${server.name} listening to ${server.url}`);
});
// Create adapter and listen to servers '/api/messages' route.
const adapter = new BotFrameworkAdapter({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD
});
server.post('/api/messages', (adapter as any).listen());
// Initialize bot by passing it adapter
const bot = new Bot(adapter);
// Define the bots onReceive message handler
bot.onReceive((context) => {
if (context.request.type === 'message') {
context.reply(`Hello World`);
}
});