Ingest Discord messages, threads, and forum posts into CortexDB.
Discord Connector
Captures messages from configured Discord channels and forums as CortexDB experiences. Uses the Discord Gateway for real-time events.
Info
Two ways to run this connector:
- Run it yourself (Free + paid) —
pip install 'cortexdb-connectors[discord]'thencortexdb-sync sync discord. The connector reads your token from~/.cortexdb/state.json(written bycortexdb init) or from env vars. - Managed sync (Starter and up) — CortexDB runs the connector as a worker on its infrastructure. Configure it once from your dashboard; CortexDB handles webhook registration, retries, backfill, and idempotency.
1. Prepare credentials in Discord
- discord.com/developers/applications → New Application.
- Bot → Add Bot. Copy the bot token.
- Privileged Gateway Intents: enable Message Content Intent.
- OAuth2 → URL Generator → scopes:
bot; permissions:View Channels,Read Message History. Invite the bot to your server.
2. Configure in your CortexDB dashboard
- Sign in at cortexdb.ai/login.
- Settings → Connectors → Add Connector → Discord.
- Paste the bot token.
- Pick the guilds (servers) to sync (comma-separated IDs).
- Set the scope template. Default:
org:<your-org>/source:discord/guild:{guild_id}/channel:{channel_id}. - Click Start sync.
What gets written
| Event | Modality | Notes |
|---|---|---|
| Channel message | conversation | role=user; reactions as labels |
| Thread reply | conversation | preceded_by links the thread parent |
| Forum post | document | Title + body |
| Voice transcript (if Cleo bot is connected) | conversation | Speaker as observed_actor |
idempotency_key shape: dc:<guild>:<channel>:<message_id>.
Run it yourself
If you'd rather host the connector yourself instead of using CortexDB's managed worker, every connector ships in the cortexdb-connectors PyPI package:
pip install 'cortexdb-connectors[discord]'
# Step 1: get a CortexDB token + actor (one-time, free tier)
pip install cortexdb-cli
cortexdb init
# Step 2: supply the connector's third-party credentials
export DISCORD_BOT_TOKEN=... # required
# Step 3: one-shot sync, or `watch` for a poll loop
cortexdb-sync sync discord
cortexdb-sync watch discord --interval 60
cortexdb-sync reads your CortexDB token + actor from ~/.cortexdb/state.json automatically. Cursor state is persisted in ~/.cortexdb/connectors-state.json, so re-running picks up where the last cycle left off.
See also
- Slack Connector — same pattern for Slack
- POST /v1/experience