This repository holds a simple go application which is at the same time a client/bot
for the https://slack.com/ system as well as a simplistic websocket server which
speaks a {nickname:str, msg:str} JSONL protocol which allows to trivially
implement a client side chat service in a website. This way, externals can
quickly communicate within a slack channel without authentification.
This is inspired by the matrix bridge. The go code is basically vibe coded, with minor enhancements.
In order to run the bot, you need two credentials:
- Slack app token: Go to https://api.slack.com/apps
and click on create new app. The token begins with
xapp-... - Slack bot token: Install your app in a slack org.
You then get the bot user OAuth token displayed, which begins
with
xoxb-...
Currently there are no slash commands or so, you have to decide at runtime
which channel the bot shall join. This reads something like
C1234567ABC and can be read off the URL when opening the channel in the
browser.
In order to test the code, run it like
# defining your slack workspace
export SLACK_BOT_TOKEN="xoxb-..."
# defining your bot/app
export SLACK_APP_TOKEN="xapp-..."
# defining your channel
export SLACK_CHANNEL_ID="C1234567ABC"
export WS_ADDR=":8080" # optional
export PEOPLE_POLL_INTERVAL="30s" # optional
# export COUNT_BOTS_AS_PEOPLE=false # optional
go run .
For testing locally, spin up websocat ws://localhost:8080/ws
and test chatting.
The repo brings a Makefile and Dockerfile for generating a slim container. It also contains the k8s definitions for the deployment made. Since this is a write-once project, we don't have CI/CD and ship manually.
Restarting the pod with a new code means basically
export KUBECONFIG="..." # make sure you have access
make docker
kubectl rollout restart deployment ws-chat-to-slack -n svenk
The deployment is currently taking place to https://ws-chat-to-slack.denktmit.tech/ws