Skip to content

feat(channels): add Discord adapter (#625) - #656

Merged
molecule-ai[bot] merged 1 commit into
mainfrom
feat/issue-625-discord-adapter-clean
Apr 17, 2026
Merged

molecule-ai[bot] merged 1 commit into
mainfrom
feat/issue-625-discord-adapter-clean

Conversation

@molecule-ai

@molecule-ai molecule-ai Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the Discord channel adapter so Community Manager (and any other workspace) can send messages to Discord and receive inbound slash commands.

  • platform/internal/channels/discord.goDiscordAdapter implementing ChannelAdapter:
    • ValidateConfig: requires webhook_url starting with https://discord.com/api/webhooks/ (matches the Slack SSRF-guard pattern)
    • SendMessage: POSTs {"content": text} to the webhook; splits messages >2000 chars at newline/space boundaries (Discord hard limit)
    • ParseWebhook: handles type-1 PING (returns nil — router layer must respond {"type":1}), type-2 APPLICATION_COMMAND, type-3 MESSAGE_COMPONENT; extracts text as /commandname option1 option2; prefers member.user over user (guild vs DM)
    • StartPolling: returns nil (Discord uses Interactions webhook, not long-polling)
  • platform/internal/channels/discord_test.go — 20 unit tests (ValidateConfig × 6, SendMessage error paths × 2, ParseWebhook × 5, StartPolling, registry × 2, splitMessage × 4)
  • platform/internal/channels/registry.go — register "discord": &DiscordAdapter{}
  • .env.example — document DISCORD_WEBHOOK_URL

Org-template change (separate repo)

community-manager/workspace.yaml in molecule-ai-org-template-molecule-dev will be updated in a companion PR to wire DISCORD_WEBHOOK_URL into the Community Manager's channel config. Community Manager is the natural owner — its role description explicitly calls out Discord triage.

Setup instructions

  1. Discord Server → channel → Edit Channel → Integrations → Webhooks → New Webhook → Copy Webhook URL
  2. Add as global secret: POST /settings/secrets {"key":"DISCORD_WEBHOOK_URL","value":"https://discord.com/api/webhooks/..."}
  3. For inbound slash commands: create a Discord Application, set Interactions Endpoint URL to https://<platform-host>/webhooks/discord

Test plan

  • go test ./platform/internal/channels/... passes (all 20 new Discord tests + existing)
  • GET /channels/adapters returns {"type":"discord","display_name":"Discord"} in list
  • Create a workspace channel via Canvas or API with type=discord and a valid webhook URL; verify POST /workspaces/:id/channels/:id/test sends a test message to Discord

Closes #625

🤖 Generated with Claude Code

Implements DiscordAdapter conforming to the ChannelAdapter interface,
using Discord Incoming Webhooks for outbound messages and the Interactions
endpoint for inbound slash commands.

Changes:
- platform/internal/channels/discord.go: DiscordAdapter + splitMessage
  helper (Discord enforces 2000-char limit; long messages are split at
  newline/space boundaries). ParseWebhook handles type-1 PING (returns
  nil so the router layer can respond), type-2 APPLICATION_COMMAND, and
  type-3 MESSAGE_COMPONENT payloads. ValidateConfig rejects non-discord
  webhook URLs (SSRF guard matches Slack pattern).
- platform/internal/channels/discord_test.go: 20 unit tests covering
  Type/DisplayName, ValidateConfig (valid + 5 invalid cases), SendMessage
  error paths, ParseWebhook (PING / slash command / DM user / unknown type /
  invalid JSON), StartPolling, GetAdapter registry lookup, ListAdapters
  inclusion, and splitMessage edge cases.
- platform/internal/channels/registry.go: register "discord" adapter.
- .env.example: document DISCORD_WEBHOOK_URL.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
molecule-ai Bot pushed a commit to Molecule-AI/molecule-ai-org-template-molecule-dev that referenced this pull request Apr 17, 2026
Adds a Discord channel entry to community-manager/workspace.yaml so the
Community Manager workspace can send alerts and receive slash commands
via Discord. Requires DISCORD_WEBHOOK_URL set as a global secret.

Companion to EnterOS-AI/enter-os-core#656 (Discord adapter).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@molecule-ai
molecule-ai Bot merged commit 1ffa33c into main Apr 17, 2026
4 of 5 checks passed
@molecule-ai
molecule-ai Bot deleted the feat/issue-625-discord-adapter-clean branch April 17, 2026 07:30
molecule-ai Bot pushed a commit that referenced this pull request Apr 21, 2026
- Mark discord as ✅ Implemented (was: Planned)
- Add Discord Setup section with webhook config, Canvas steps, API example
- Document slash command inbound + webhook outbound architecture

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
molecule-ai Bot pushed a commit that referenced this pull request Apr 21, 2026
Announcement copy for PR #656 — Discord adapter shipped.
Platforms: Discord, Reddit r/LocalLLama, dev.to.
Coordination note: thread #1182 timing TBD — flag for Social Media Brand.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
molecule-ai Bot added a commit that referenced this pull request Apr 21, 2026
…er-clean

feat(channels): add Discord adapter (#625)
molecule-ai Bot pushed a commit that referenced this pull request Apr 21, 2026
- Mark discord as ✅ Implemented (was: Planned)
- Add Discord Setup section with webhook config, Canvas steps, API example
- Document slash command inbound + webhook outbound architecture

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
molecule-ai Bot pushed a commit that referenced this pull request Apr 21, 2026
Announcement copy for PR #656 — Discord adapter shipped.
Platforms: Discord, Reddit r/LocalLLama, dev.to.
Coordination note: thread #1182 timing TBD — flag for Social Media Brand.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Channel proposal: Discord adapter + Community Manager workspace channel

0 participants