Loading…
Slack Consolidate: a slackbot built with Python and Supabase
Rodrigo Mansueli
- Source
- Supabase
- Published
- Added to Yomu
Summary
Slack Consolidate is a Python Slackbot that watches configured Slack channels and reposts messages to destination channels according to routing rules stored in Supabase. The tutorial sets up Slack app permissions from a manifest, installs the Python SDKs, configures environment variables for Supabase and Slack tokens, and creates slack_channels and slack_watcher PostgreSQL tables. Its polling loop loads channel mappings, fetches up to 20 recent messages, converts Slack timestamps to ISO-compatible values, inserts messages into the watcher table, builds message links, and posts through a bot client; it waits 1.4 seconds between channel processing and rescans channel configuration hourly. Public-channel posts contain a link, while private-channel posts include the message text as well. The project also provides a Google Colab notebook for trying the example.
Context
The bot is intended to consolidate messages from watched Slack channels into configured destination channels, with routing rules that can separate messages into smaller buffers such as VIP or Enterprise. The source also describes storing watched-channel data and processed messages in Supabase tables.
Approach / What changed
Create a Slack app with the required manifest scopes, configure Supabase and Slack credentials through environment variables, and populate the slack_channels and slack_watcher tables. A Python loop uses the Slack SDK to read recent messages, stores them in Supabase, creates Slack message links, and posts formatted notifications with a bot client. Channel configuration is refreshed every hour.
Takeaways
- The slack_channels table maps source channel IDs to destination channel IDs and stores an optional p_level label plus a private-channel flag.
- The polling implementation requests up to 20 messages per channel, stores message timestamps and millisecond components, and uses a 1.4-second delay to avoid passing Slack API limits.
- For public channels, the posted notification includes the source channel and message link; for private channels, it also includes the message text.