Skip to content

Commit f8ffb61

Browse files
fix(slack): replace bolt with web-api to prevent server startup issues
1 parent eeb6164 commit f8ffb61

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

functions/billing/index.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,14 @@ const PROJECT_NAME = `projects/${PROJECT_ID}`;
2323
// [END functions_billing_limit]
2424

2525
// [START functions_billing_slack]
26-
const {App} = require('@slack/bolt');
26+
const {WebClient} = require('@slack/web-api');
2727

2828
// TODO(developer) replace these with your own values
2929
const BOT_ACCESS_TOKEN =
3030
process.env.BOT_ACCESS_TOKEN || 'xxxx-111111111111-abcdefghidklmnopq';
31-
const SLACK_SIGNING_SECRET =
32-
process.env.SLACK_SIGNING_SECRET || 'default-signing-secret';
3331
const CHANNEL = process.env.SLACK_CHANNEL || 'general';
3432

35-
const app = new App({
36-
token: BOT_ACCESS_TOKEN,
37-
signingSecret: SLACK_SIGNING_SECRET,
38-
});
33+
const slackClient = new WebClient(BOT_ACCESS_TOKEN);
3934

4035
exports.notifySlack = async pubsubEvent => {
4136
const pubsubAttrs = pubsubEvent.attributes;
@@ -45,8 +40,7 @@ exports.notifySlack = async pubsubEvent => {
4540
)}, ${pubsubData}`;
4641

4742
try {
48-
await app.client.chat.postMessage({
49-
token: BOT_ACCESS_TOKEN,
43+
await slackClient.chat.postMessage({
5044
channel: CHANNEL,
5145
text: budgetNotificationText,
5246
});

functions/billing/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"dependencies": {
1717
"@google-cloud/billing": "^4.0.0",
1818
"@google-cloud/compute": "^4.0.0",
19-
"@slack/bolt": "^4.2.1",
19+
"@slack/web-api": "^7.9.1",
2020
"google-auth-library": "^9.0.0",
2121
"googleapis": "^143.0.0"
2222
},

0 commit comments

Comments
 (0)