From 7f93381918fd130c9b77d514acfca65ed068e3a9 Mon Sep 17 00:00:00 2001 From: Angel Caamal Date: Fri, 10 Apr 2026 20:19:43 +0000 Subject: [PATCH 1/2] chore(billing): migrate deprecated slack package to @slack/web-api --- functions/billing/index.js | 6 +++--- functions/billing/package.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/billing/index.js b/functions/billing/index.js index 38d3bdfe5a..a3da303758 100644 --- a/functions/billing/index.js +++ b/functions/billing/index.js @@ -23,12 +23,13 @@ const PROJECT_NAME = `projects/${PROJECT_ID}`; // [END functions_billing_limit] // [START functions_billing_slack] -const slack = require('slack'); +const {WebClient} = require('@slack/web-api'); // TODO(developer) replace these with your own values const BOT_ACCESS_TOKEN = process.env.BOT_ACCESS_TOKEN || 'xxxx-111111111111-abcdefghidklmnopq'; const CHANNEL = process.env.SLACK_CHANNEL || 'general'; +const web = new WebClient(BOT_ACCESS_TOKEN); exports.notifySlack = async pubsubEvent => { const pubsubAttrs = pubsubEvent.attributes; @@ -37,8 +38,7 @@ exports.notifySlack = async pubsubEvent => { pubsubAttrs )}, ${pubsubData}`; - await slack.chat.postMessage({ - token: BOT_ACCESS_TOKEN, + await web.chat.postMessage({ channel: CHANNEL, text: budgetNotificationText, }); diff --git a/functions/billing/package.json b/functions/billing/package.json index 0c59d6c3e9..a10958973f 100644 --- a/functions/billing/package.json +++ b/functions/billing/package.json @@ -16,9 +16,9 @@ "dependencies": { "@google-cloud/billing": "^4.0.0", "@google-cloud/compute": "^4.0.0", + "@slack/web-api": "^7.15.0", "google-auth-library": "^9.0.0", - "googleapis": "^143.0.0", - "slack": "^11.0.1" + "googleapis": "^143.0.0" }, "devDependencies": { "@google-cloud/functions-framework": "^3.0.0", From c45139d71a1d12196c4614f8e8c167bd3a27342c Mon Sep 17 00:00:00 2001 From: Angel Caamal Date: Fri, 10 Apr 2026 20:25:53 +0000 Subject: [PATCH 2/2] fix(billing): update node engine to >=18.0.0 for slack web-api compatibility --- functions/billing/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/billing/package.json b/functions/billing/package.json index a10958973f..5630dfb8a4 100644 --- a/functions/billing/package.json +++ b/functions/billing/package.json @@ -5,7 +5,7 @@ "description": "Examples of integrating Cloud Functions with billing", "main": "index.js", "engines": { - "node": ">=16.0.0" + "node": ">=18.0.0" }, "scripts": { "compute-test": "c8 mocha -p -j 2 test/periodic.test.js --timeout=600000",