-
Notifications
You must be signed in to change notification settings - Fork 773
/
botController.js
37 lines (30 loc) · 1.24 KB
/
botController.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
const { BotFrameworkAdapter } = require('botbuilder');
const { BotActivityHandler } = require('../bot/botActivityHandler');
const adapter = new BotFrameworkAdapter({
appId: process.env.BotId,
appPassword: process.env.BotPassword
});
adapter.onTurnError = async (context, error) => {
// This check writes out errors to console log .vs. server insights.
// NOTE: In production environment, you should consider logging this to Azure
// serverlication insights.
console.error(`\n [onTurnError] unhandled error: ${ error }`);
// Send a trace activity, which will be displayed in Bot Framework Emulator
await context.sendTraceActivity(
'OnTurnError Trace',
`${ error }`,
'https://www.botframework.com/schemas/error',
'TurnError'
);
// Uncomment below commented line for local debugging.
// await context.sendActivity(`Sorry, it looks like something went wrong. Exception Caught: ${error}`);
};
// Create bot handlers
const botActivityHandler = new BotActivityHandler();
const botHandler = (req, res) => {
adapter.processActivity(req, res, async (context) => {
// Process bot activity
await botActivityHandler.run(context);
});
}
module.exports = botHandler;