Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions functions/billing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
});
Expand Down
6 changes: 3 additions & 3 deletions functions/billing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Loading