- Go
- PostgreSQL
- Vanilla JS
- Tailwind CSS
- OpenTelemetry
- Slack
Chat Roulette for Slack was designed to be able to run on the free tier of the various PaaS providers such as Heroku, fly.io, render, etc. The compiled binary is completely standalone with all required files baked into it using embed.FS. The only dependency is PostgreSQL. The application is horizontally scalable.
An effort was made to limit storing any personally identifiable information in the database. Only Slack identifiers (eg, U0123456789
) are saved and not display names (eg, @bincyber
). For privacy and security reasons, all user data is encrypted at rest using Column-level encryption with 256-bit AES in Galois/Counter Mode (GCM).
The application consists of two components:
-
a web server which receives and handles events and interactions from Slack
-
a background worker which processes jobs in a PostgreSQL queue
For local development, docker and ngrok need to be installed. Docker is used to run the PostgreSQL server. ngrok is used to create a HTTPS tunnel enabling Slack to send webhooks to the application.
The following tools are also required:
To install these tools to $GOPATH/bin
, run the following command:
make go/tools
Start an https tunnel using ngrok with the following command:
make ngrok
Copy the generated forwarding URL:
ngrok by @inconshreveable (Ctrl+C to quit)
Session Status online
Account bincyber (Plan: Free)
Version 3.14.0
Web Interface http://127.0.0.1:4040
Forwarding https://36a1-5-193-74-226.ngrok-free.app -> http://localhost:8080
To install the Chat Roulette for Slack app in your Slack workspace, do the following:
- Visit https://api.slack.com/apps and generate an App Configuration token:
Copy the access token:
- Run the app-manifest-installer CLI to install the Slack app using the provided App Manifest:
go run cmd/app-manifest/main.go -u <NGROK URL HERE> -t <xoxe.xoxp-1-SlackAppConfigurationAccessTokenHere>
- Refresh your browser to view the new Slack app, then click on it. Scroll down to
Display Information
and click onAdd App Icon
to set the image for the bot:
Upload the image in docs/images/bot-icon.png.
- On the left-hand menu under
Features
, click onOAuth & Permissions
. Click theInstall to Workspace
button to install the Chat Roulette for Slack app to your Slack Workspace.
You will need to accept the requested permissions:
Note: You will need sufficient permissions on your Slack workspace to install the app and complete the above step.
-
Copy the
Bot User OAuth Token
. Open theconfig.json
file and set the copied bot token for the value"auth_token"
. -
On the left-hand menu under
Features
, click onApp Manifest
. After the app is deployed to fly.io, you will need to verify URL ownership by clicking on the button in the banner.
To bring up the development environment:
make dev/up
This will start the PostgreSQL server in a Docker container, execute database migration, and run the Go app on your machine.
To restart the application, press Ctrl+C
and then:
make go/run
To terminate the development environment:
make dev/destroy
This application is instrumented with OpenTelemetry to emit traces to Honeycomb or Jaeger.
Tracing can be enabled by adding the following settings to the config file:
"tracing": {
"enabled": true,
"exporter": "honeycomb",
"honeycomb": {
"team": "honeycomb-api-key-here",
"dataset": "chat-roulette"
}
}
"tracing": {
"enabled": true,
"exporter": "jaeger",
"jaeger": {
"endpoint": "http://localhost:4318/api/traces"
}
}
To run the test suite:
make go/testsum
Some tests use ory/dockertest which requires access to the Docker socket (ie, /var/run/docker.sock
).