forked from molecule-ai/molecule-core
docs: update social-channels.md — Discord adapter shipped (PR #656)
- 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>
This commit is contained in:
parent
128e5ade79
commit
e30625628f
@ -24,7 +24,7 @@ The `channel:<type>` caller prefix bypasses workspace hierarchy access checks (s
|
||||
|------|--------|---------|
|
||||
| `telegram` | ✅ Implemented | `go-telegram-bot-api/v5` |
|
||||
| `slack` | Planned | — |
|
||||
| `discord` | Planned | — |
|
||||
| `discord` | ✅ Implemented (PR #656) | native `net/http` |
|
||||
| `whatsapp` | Planned | — |
|
||||
|
||||
To add a new adapter: implement `ChannelAdapter` in `workspace-server/internal/channels/`, register in `registry.go`. Everything else (CRUD API, Canvas UI, MCP tools) works automatically.
|
||||
@ -129,6 +129,43 @@ The vars are resolved from (in order): `pm/.env` → org root `.env` → platfor
|
||||
|
||||
The platform calls `adapter.ValidateConfig()` upfront so unknown channel types or invalid configs fail fast. Insert is idempotent (`ON CONFLICT DO UPDATE`) so re-importing the same org refreshes the channel config.
|
||||
|
||||
## Discord Setup
|
||||
|
||||
### 1. Create a Discord Webhook
|
||||
1. Open your Discord server → **Edit Channel** (or create a new one) → **Integrations** → **Webhooks**
|
||||
2. Click **New Webhook** → name it → **Copy Webhook URL**
|
||||
3. The URL looks like: `https://discord.com/api/webhooks/<id>/<token>`
|
||||
|
||||
### 2. Connect via Canvas
|
||||
1. Open the workspace in Canvas → **Channels** tab → **+ Connect**
|
||||
2. Paste the webhook URL
|
||||
3. **Connect Channel**
|
||||
|
||||
### 3. Or connect via API
|
||||
```bash
|
||||
curl -X POST http://localhost:8080/workspaces/:id/channels \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"channel_type": "discord",
|
||||
"config": {
|
||||
"webhook_url": "https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN"
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
### 4. Register slash commands (for inbound)
|
||||
Discord uses Application Commands (slash commands) for inbound messages. Register them in your Discord server's **Integration** page, or use Discord's developer portal to create global commands. The adapter parses `/<command> <options>` and passes them to the workspace agent.
|
||||
|
||||
### Inbound / Outbound
|
||||
| Direction | Mechanism |
|
||||
|---|---|
|
||||
| **Inbound** | Discord Interactions endpoint (slash commands, message components) → `ParseWebhook()` |
|
||||
| **Outbound** | Discord Incoming Webhooks → `SendMessage()` (2000-char chunking built in) |
|
||||
|
||||
**Note:** No Discord bot token is required for outbound-only use — the webhook URL encodes channel + token. For inbound slash commands, you need a Discord Application with an Interactions endpoint URL pointed at `POST /webhooks/discord` on your platform.
|
||||
|
||||
See `workspace-server/internal/channels/discord.go` for the full adapter implementation.
|
||||
|
||||
## Hot Reload
|
||||
|
||||
CRUD operations on `/workspaces/:id/channels` (POST, PATCH, DELETE) trigger `manager.Reload()`. Active polling goroutines are diffed against the desired DB state — new channels start, removed/disabled ones stop. No platform restart required.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user