File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,12 +23,13 @@ const PROJECT_NAME = `projects/${PROJECT_ID}`;
2323// [END functions_billing_limit]
2424
2525// [START functions_billing_slack]
26- const slack = require ( 'slack' ) ;
26+ const { WebClient } = require ( '@ slack/web-api ' ) ;
2727
2828// TODO(developer) replace these with your own values
2929const BOT_ACCESS_TOKEN =
3030 process . env . BOT_ACCESS_TOKEN || 'xxxx-111111111111-abcdefghidklmnopq' ;
3131const CHANNEL = process . env . SLACK_CHANNEL || 'general' ;
32+ const slackClient = new WebClient ( BOT_ACCESS_TOKEN ) ;
3233
3334exports . notifySlack = async pubsubEvent => {
3435 const pubsubAttrs = pubsubEvent . attributes ;
@@ -37,8 +38,7 @@ exports.notifySlack = async pubsubEvent => {
3738 pubsubAttrs
3839 ) } , ${ pubsubData } `;
3940
40- await slack . chat . postMessage ( {
41- token : BOT_ACCESS_TOKEN ,
41+ await slackClient . chat . postMessage ( {
4242 channel : CHANNEL ,
4343 text : budgetNotificationText ,
4444 } ) ;
Original file line number Diff line number Diff line change 55 "description" : " Examples of integrating Cloud Functions with billing" ,
66 "main" : " index.js" ,
77 "engines" : {
8- "node" : " >=16 .0.0"
8+ "node" : " >=18 .0.0"
99 },
1010 "scripts" : {
1111 "compute-test" : " c8 mocha -p -j 2 test/periodic.test.js --timeout=600000" ,
1616 "dependencies" : {
1717 "@google-cloud/billing" : " ^4.0.0" ,
1818 "@google-cloud/compute" : " ^4.0.0" ,
19+ "@slack/web-api" : " ^7.15.0" ,
1920 "google-auth-library" : " ^9.0.0" ,
20- "googleapis" : " ^143.0.0" ,
21- "slack" : " ^11.0.1"
21+ "googleapis" : " ^143.0.0"
2222 },
2323 "devDependencies" : {
2424 "@google-cloud/functions-framework" : " ^3.0.0" ,
You can’t perform that action at this time.
0 commit comments