Skip to content

Instantly share code, notes, and snippets.

@fivesheep
Created December 1, 2021 18:22
Show Gist options
  • Save fivesheep/4dafd36bd4eec9d818cfda8ba710748a to your computer and use it in GitHub Desktop.
Save fivesheep/4dafd36bd4eec9d818cfda8ba710748a to your computer and use it in GitHub Desktop.

create a slackbot to fetch text events from an internal api and send it to a dedicated slack channel

slack bot api can be found from:

https://slack.dev/python-slack-sdk/web/index.html#messaging

our internal api has two endpoints:

  1. /api/events/latest (a GET api to get a list of latest events, not acked)
[
  {"id": "uid-1", "message": "test message", "epoch": 15000000},
  {"id": "uid-2", "message": "test message 2", "epoch": 15000000},
  ...
]
  1. /api/events/ack (a POST api to acknowledge an event has been processed. It will remove events with the provided ids from the latest response) payload:
[ "uid-1", "uid-2"]

requirements:

  1. able to push the latest events to a specified slack channel with proper error handling
  2. timely (send out the message asap)
  3. high availability
  4. shall not send duplicated messages to the channel

we would like this run in k8s

task:

  1. app implementation
  2. dockerize can use base image python:3.9.7-slim-buster
  3. deployment strategy (k8s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment