feat: Slack and Discord service integrations#24
Open
joshupadhyay wants to merge 4 commits intohdresearch:mainfrom
Open
feat: Slack and Discord service integrations#24joshupadhyay wants to merge 4 commits intohdresearch:mainfrom
joshupadhyay wants to merge 4 commits intohdresearch:mainfrom
Conversation
Extracted loadVersConfigOverride + cache into services/shared/config.ts. All three services now share one config cache instead of three copies (Slack had no cache at all — sync disk I/O on every call). Also extracted resolveConfig() and escapeHtml() into shared module. Fixes from code review: - Fixed undefined isNotificationsMuted/reefAuthToken in Discord (crash) - Fixed dead ternary in formatNotificationForDiscord (all branches identical) - Fixed notification debounce (was resetting timer, deferring indefinitely) - Added TTL expiry to externalTaskIds (memory leak on orphaned tasks) - Replaced magic "hello" fallback with descriptive prompt - Added SETUP.md documentation for Discord, Slack, and Notifications Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Removed the HTTP polling loop (240 requests per message, 4-min timeout) and replaced with a direct event bus listener. The ServiceEventBus is required — no fallback polling path. Reef guarantees every task emits task_done or task_error (even on crash via child.on close), so no timeout is needed. Tasks now wait as long as they take. Also removed dead polling fallback code (~50 lines). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Discord:
- Real invite link with correct permissions (274877975616)
- reef_discord_setup tool returns invite link
- Each @mention gets its own reef conversation (discord-{channel}-{messageId})
Slack:
- Add to Slack link with all required scopes
- reef_slack_setup tool returns install link
- Thread-based conversations: each top-level @mention starts a new
reef conversation, replies in thread continue it
- Bot always replies in-thread to keep channels clean
Both services: reef_*_configure demoted to BYO-token fallback,
reef_*_setup is the default path for users.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
joshupadhyay
commented
Mar 27, 2026
joshupadhyay
commented
Mar 27, 2026
| "SLACK_NOTIFICATION_CHANNEL", | ||
| "SLACK_APP_TOKEN", | ||
| "DISCORD_APP_ID", | ||
| ]); |
Author
There was a problem hiding this comment.
new ENV vars with varying notif levels, I'm sure we can pare these down but
049913e to
d0fa25b
Compare
…euristic The invite routes and setup tools were comparing app IDs against hardcoded defaults to determine if the bot was "configured", which always returned false since the default IS the real Vers bot. Now checks actual token validity and gateway/socket connection status, returning "already connected" when the bot is live. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Author
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Summary
Adds Slack and Discord as reef service modules — bidirectional messaging, proactive event notifications, and a centralized notifications architecture.
Currently, this creates a new chat in 'reef' for each thread you have with the bot. The bot will start a thread to each message (not each channel). This way, the context from the thread is passed cleanly via a thread id.
@Claudeworks slightly differently:Claude Code pulls information contextually, which we can totally adjust to. I just found this as a better MVP. In this implementation, each thread becomes a new chat in the reef. That way the context for the chat -> is the thread.
usage:
message the reef about discord / slack
use the invite code, add the bot
tag the bot @username!
to continue conversations with a certain context, start a thread and keep replying.
services/shared/messaging.ts(reef submit, event bus wait, tag stripping, message splitting) andservices/shared/config.ts(cached vers-config resolution, shared across all services)What works today
What still needs to be done
Official Vers bots
Currently uses BYO tokens — each user creates their own Discord app / Slack app. The target state:
GET /discord/inviteroute exists with placeholderDISCORD_APP_ID.vers.sh/api/slack/oauth/callback) to store per-workspace tokens.See
DISCORD_INTEGRATION_PLAN.mdfor the full migration plan.Slack reactions
Slack reactions (👀→✅/❌) require the
reactions:writescope. Need to add to required scopes and verify.Reef agent instructions
When a user asks for Discord or Slack integration, the reef agent should return an invite/install link for the official Vers bot instead of BYO-token instructions.
Architecture
New files
services/discord/index.tsservices/discord/SETUP.mdservices/discord/DISCORD_BOT.mdservices/discord/DISCORD_INTEGRATION_PLAN.mdservices/slack/index.tsservices/slack/SETUP.mdservices/notifications/index.tsservices/notifications/SETUP.mdservices/shared/messaging.tsservices/shared/config.tsModified files
services/vers-config/index.tssrc/reef.tsEnvironment variables
Discord
DISCORD_BOT_TOKENDISCORD_APP_IDDISCORD_NOTIFICATION_CHANNEL_IDSlack
SLACK_BOT_TOKENSLACK_APP_TOKENSLACK_NOTIFICATION_CHANNELNotifications
NOTIFICATION_MUTE"true"to mute all notifications globallyNOTIFICATION_MIN_DURATION_MSSlack bot required scopes
chat:write,chat:write.public,channels:read,channels:history,im:history,im:read,im:write,app_mentions:read,reactions:read,reactions:write,users:readSlack required event subscriptions
app_mention,message.imSlack required settings
Socket Mode: ON, App Home > Chat Tab: ON, "Allow users to send Slash commands and messages from the chat tab": checked
🤖 Generated with Claude Code