Skip to content

Latest commit

 

History

History

v_alpha

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

GCP Serverless Slackbot Template - alpha version

Minimalistic code to create a serverless slash handler for a Slack bot. Further information on this repository can be found in the article Google Cloud Platform - Serverless Slack Bot

Deploy

This cloud function can be deployed to the current google project: gcloud functions deploy hello_bot --runtime python37 --trigger-http

The function permissions will need to be updated to grant allUsers the Cloud Functions Invoker role. This makes the function publicly available to be invoked from Slack.

Directory contents

config.json

Configuration information used at runtime. Update the SLACK_TOKEN and WEBHOOK_URL here for your environment/project.

main.py

python implementation of a slash handler Slack bot. Config is read when the function is loaded by the line

config = json.loads(open('config.json', 'r').read())

The entry point is:

def hello_bot(request):

Execution then consists of:

  • validate the slack token is correct
  • validate the request
  • execute the request or return an error message