With that safely saved away, the one factor you want is a channel that you simply need to ship messages to. I’ve used a channel referred to as “budget-alerts” (do not embrace the #) however I might counsel utilizing a brand new channel somewhat than an present one at the very least to start out!

Observe: You may additionally have to go to your channel and run a command to ask the bot into the channel the place you need it to put up. You may need to replace the bot title primarily based on the title you supplied.

/invite @budget_alert_bot

Again to the cloud!

Now that we have now the token and channel, head again to the Google Cloud Console and create a brand new Google Cloud Perform. For those who adopted the steps from the final put up, you may depart your logger bot or shut it down, since Pub/Sub permits a number of subscribers to a subject. Select a reputation like “budget-notification-slack” and ensure to decide on the identical Pub/Sub matter. If you’d like a refresher on making a perform, the last post has a bit extra data.

As soon as once more, we’ll use Python 3.7, however this time we’ll change the code. By default, you may have two recordsdata on the left, essential.py and necessities.txt. I will not go into any Python specifics right here however click on on necessities.txt and add this line of code:


Here is an image to verify the whole lot is sweet:

Leave a Reply

Your email address will not be published. Required fields are marked *