-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
85 lines (78 loc) · 1.84 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const { App } = require('@slack/bolt');
const dotenv = require('dotenv').config();
const { leadModalHandler } = require('./views/leadModal');
const { leadModalSubmissionHandler } = require('./controllers/leadModal');
const app = new App({
token: process.env.access_token,
signingSecret: process.env.signing_secret,
clientId: process.env.clientI_id,
clientSecret: process.env.client_secret
});
app.command('/lead', async ({ ack, body, client }) => {
try {
await ack();
body.channel = { id: body.channel_id };
leadModalHandler(body, client);
} catch (error) {
console.log(error);
}
});
app.event('app_mention', async ({ event, client }) => {
try {
await client.chat.postEphemeral({
token: process.env.access_token,
channel: event.channel.startsWith('D') ? event.user : event.channel,
user: event.user,
blocks: [
{
type: 'section',
text: {
type: 'mrkdwn',
text: 'Please click on the button below to open lead modal.'
}
},
{
type: 'actions',
elements: [
{
type: 'button',
style: 'primary',
text: {
type: 'plain_text',
text: 'Open Lead Modal',
emoji: true
},
action_id: 'lead_modal'
}
]
}
]
});
} catch (error) {
console.log(error);
}
});
(async () => {
try {
await app.start(process.env.PORT || 5082);
console.log('Solbot is running!');
} catch (error) {
console.log(error);
}
})();
app.view('lead_modal', async ({ ack, body, client }) => {
try {
await ack();
leadModalSubmissionHandler(body, client);
} catch (error) {
console.log(error);
}
});
app.action('lead_modal', async ({ ack, body, client }) => {
try {
await ack();
leadModalHandler(body, client);
} catch (error) {
console.log(error);
}
});