Serverless Slack Bot with GCP

Shubham Dangare
3 min readJun 23, 2021


Slack Bot integration serverless using GCP cloud function

In this post, I’ll show you how I built a Slack Bot with Python. In addition, I’ll show you how to overcome a common issue when working with APIs and how a unique Cloud Functions pattern can help you overcome this obstacle.

After some research, I learned that Slack only gives you three seconds to respond to a slash command

The user experience is:

  • ✅ a request to the bot
  • ❌ a timeout message from Slack
  • ✅ the response from the bot

To Solve this problem we are going to use GCP Pubsub pipeline

For started we need to create Service account in GCP with following role attached to it which i will explain later y are they required

Now lets create pubsub topic in GCP just click on search button and tupe pub/sub -> click on create topic this below page will open in which you can add any topic name to which we can publish our message in

Once our topic is ready we can create create cloud function with service account attached in it

And will accept the form data from slack and will publish message to the pubsub topic

Code available here also

Before going further we need to create slack bot here . your bot is ready we need to configure cloud function url in slack config

Which will trigger when we send slack command from our workspace and cloud function will be called as mentioned i architecture diagram

Now that we have published message in topic now it time to retrieve the message into another cloud function and process whatever task need to be done and send back post call to response_url which get triggered in our message



Shubham Dangare

Data Engineer at Cloud Cover

Recommended from Medium