-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
38 lines (31 loc) · 973 Bytes
/
app.ts
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
import * as builder from 'botbuilder';
import * as express from 'express';
class App {
private bot: builder.UniversalBot;
private connector: builder.ChatConnector;
private connectorListener: any;
public express;
constructor() {
this.connector = new builder.ChatConnector({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD
});
this.connectorListener = this.connector.listen();
this.bot = new builder.UniversalBot(this.connector, (session) => {
session.send("You said: %s", session.message.text);
});
this.express = express();
this.mountRoutes();
}
private mountRoutes(): void {
const router = express.Router();
router.get('/', (req, res) => {
res.send('I\'m Simple Echo Bot!')
});
router.post('/api/messages', (res, req) => {
this.connectorListener(res, req);
});
this.express.use('/', router);
}
}
export default new App().express;