-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.js
30 lines (26 loc) · 1010 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
30
const { App, AwsLambdaReceiver } = require('@slack/bolt');
const Home = require('./src/home');
const Conversation = require('./src/conversation');
const awsLambdaReceiver = new AwsLambdaReceiver({
signingSecret: process.env.SLACK_SIGNING_SECRET,
});
// Initializes app with bot token and signing secret
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
receiver: awsLambdaReceiver,
// The `processBeforeResponse` option is required for all Function as a Service (FaaS)
// environments. It allows Bolt methods (e.g. `app.message`) to handle a Slack request
// before the Bolt framework responds to the request (e.g. `ack()`). This is
// important because FaaS immediately terminate handlers after the response.
processBeforeResponse: true,
});
try {
new Home(app);
new Conversation(app);
} catch (error) {
console.error(error);
}
module.exports.handler = async (event, context, callback) => {
const handler = await app.start();
return handler(event, context, callback);
};