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..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", @@ -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",