Serverless Slack Bot: Introduction for Integrating Slack Bot with Google Cloud Functions (Part 1)

Chamal Gomes
Oct 14 · 3 min read

This is post is introducing you to how to get started with a basic Slack bot and integrate it with Google Cloud Functions for a serverless request-response function. We will be creating a basic slash command to get you started on Slack functionalities, which is to receive a simple response to any message you send on slack.

Guide your self to Slack Api Web page as follows and click “Create New App”.

Then enter any name for your app, keep in mind that the app which you create is only available on your workspace.

Next click on the Basic Information, where you will find the“slack token”. We will use it later.

Next, visit the Google cloud functions page, and sign in with your Google account.

Once successfully logged in and activated the correct project, activate the cloud shell on the top right corner.

Give it about 1 minute to open up a CLI. Once opened type in the following commands respectively.

$ cd /tmp$ mkdir SlackApp$ cd SlackApp

Now we are required to create 2 primary files,

  1. ( Where we locate the source code for the cloud function)
  2. config.json ( Where we enter our slack app credentials )

Next in the config.json copy-paste your slack verification credentials as follows. Note the USER_ID is optional, which is included to make sure only you can access the CBOT from the workspace and not anyone else.


Once the 2 files are saved type the following command within the directory to deploy the function

$ gcloud deploy hi_bot --trigger-http --runtime=nodejs8 

Allow 1–2 minutes for the function to be deployed. Once complete you will be provided with URL for the function, it usually takes the form of https://{reigon}-{projectName}{functionName}.

Next, go to your Slack App and click create slash command as follows,

Put in any name for slash command as you like, for simplicity I will name my slash command as “cbot”

In the “Request URL” section copy-paste your Cloud function URL which you obtained earlier when you deployed your function. Finally, make sure to install your slack app in your workspace.

That's it, your DONE !!!!!!

Now if you go to slack and type “/CBOT hi ” you will receive a response saying “Hello, how are you?”.

This is one of the most basic Slash commands to get you started on serverless slack app functionalities with Google Cloud Functions. As we move along you will see what sort of advanced features you can add to your slack app.

Chamal Gomes

Written by

Actuarial Research, DQL, DL, ML, Cloud Computing, RaspberryPI Dev, Education officer at MLSA University of Melbourne

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade