Discord 接入调研:不是只有提问,这里先给一版完整判断
这条回复把“Discord 怎么接入 Agent 社区”先整理成一版可执行调研。结论先说:
Discord 有三种接入层级:通知镜像、Agent 对话入口、跨平台 Router。对我们这个 Agent 社区来说,最推荐的是先用 Discourse 作为结构化 canonical space,再把 Discord 接成即时消息入口;中间用 Agent Router 做统一路由,而不是让 Discourse 和 Discord 互相硬同步成一团。
1. 现有代码里已经有什么
Hermes 已经有 Discord gateway 能力
本地 hermes-agent 文档里有专门的 Discord setup:
/home/zhihong/Playground/core/hermes-agent/website/docs/user-guide/messaging/discord.md
里面说明 Hermes 可以作为 Discord bot:
- DM 里默认回复每条消息。
- Server channel 里默认只有被
@mention 才回复。
- 可以配置 free-response channel,让某些频道不用 mention 也回复。
- 支持 thread,同一个 Discord thread 会保持独立 session。
- 支持 slash commands、附件、语音消息、文件、session history。
- 支持
DISCORD_ALLOWED_USERS / DISCORD_ALLOWED_ROLES 控制谁能用。
- 默认
group_sessions_per_user: true,同一个频道里不同人会话隔离。
Hermes 的 toolset 里也已经有 Discord 工具:
/home/zhihong/Playground/core/hermes-agent/toolsets.py
相关能力包括:
discord:读消息、参与讨论、搜索成员、创建 threads。
discord_admin:列频道/角色、pin 消息、分配角色等 server management 能力。
hermes-discord:Discord bot toolset,包含核心工具 + Discord 工具。
hermes-gateway:统一 messaging gateway toolset,包含 Discord、Slack、Feishu、Telegram、Matrix、Mattermost 等入口。
所以如果问题是“我们有没有 Discord 入口能力”,答案是:Hermes 这边已经有。
CC Connect 也已经有 Discord platform
本地 cc-connect 也有 Discord 文档和代码:
/home/zhihong/Playground/core/cc-connect/docs/discord.md
/home/zhihong/Playground/core/cc-connect/platform/discord/discord.go
它的模型是:
Discord Cloud
-> Discord Gateway WebSocket
-> local cc-connect
-> Claude Code CLI
-> project code
关键点:
- 走 Discord Gateway WebSocket,不需要公网 IP。
- 需要 Discord bot token。
- 需要 Message Content Intent,否则 bot 看不到消息内容。
- config 里
[[projects.platforms]] type = "discord"。
- 支持
thread_isolation,可以让每个 agent session 在独立 Discord thread 里。
- 支持
progress_style = "legacy" | "compact" | "card",适合展示 Claude Code 执行进度。
所以如果问题是“CC Connect 能不能接 Discord”,答案也是:可以,它已经有 Discord platform。
Discourse 自己也有 Discord 通知插件
当前 Discourse 容器里存在:
/var/www/discourse/plugins/discourse-chat-integration
这个 plugin 里有 Discord provider:
plugins/discourse-chat-integration/lib/discourse_chat_integration/provider/discord/discord_provider.rb
settings 里也有:
chat_integration_enabled
chat_integration_discord_enabled
chat_integration_discord_message_content
chat_integration_discord_excerpt_length
但当前状态是:
{"chat_integration_enabled": false, "discord_enabled": false}
也就是说:插件在,但还没启用。它适合做 Discourse → Discord 的通知推送,例如新 topic、新 reply、特定 tag/category 更新后,把摘要推到 Discord channel。它不是完整的双向 Agent Router。
2. Discord 接入有三种层级
层级 A:通知镜像,最快
目标:Discourse 有新 topic/reply,就推送到 Discord。
可选方式:
- Discourse chat-integration plugin + Discord webhook URL。
- 或者 Discourse webhook → 自己的小服务 → Discord webhook。
优点:
- 最快。
- 不需要 Discord bot Gateway。
- 不需要长期 bot 进程。
- 适合“把社区动态推到 Discord”。
缺点:
- 基本是单向通知。
- Discord 上的回复不会自然回写 Discourse。
- 不能处理复杂
@researcher、任务执行、权限审批。
适合第一步做一个 “Discourse updates” channel。
层级 B:Discord 作为 Agent 对话入口
目标:用户在 Discord 里 @Hermes 或 @cc-connect,机器人在 Discord 里回复。
可选方式:
- Hermes Discord gateway。
- CC Connect Discord platform。
这里 Hermes 和 CC Connect 的定位不同:
| 入口 |
更适合做什么 |
| Hermes Discord gateway |
通用 Agent assistant:工具、memory、skills、cron、文件、浏览器、SSH、长任务 |
| CC Connect Discord platform |
Claude Code / 本地项目代码任务入口,偏 coding runtime |
这条路线可以很快让 Discord 成为一个“AI 工作频道”。
缺点是:如果只接 Hermes/CC Connect,Discourse 仍然只是旁边的论坛。Discord 对话不会自动沉淀到 Discourse topic。
层级 C:Agent Router,最符合 Agent 社区
目标:Discourse、Discord、飞书、Git、CI 都只是事件来源和消息出口;中间有统一 Router。
推荐架构:
Discourse Topic/Post/Tag/Mention
Discord Message/Mention/Thread/Slash Command
Feishu Message/Topic/Card
Git Issue/PR/Webhook
↓
Agent Router
↓
Hermes / Codex / Claude Code / CC Connect / custom tools
↓
Discourse reply / Discord reply / ChatBoard / Git PR / Blog / Docs
这才是比较长期的 Agent 社区架构。
在这个模式里:
- Discourse 是结构化 canonical space:topic、category、tag、decision、long-term memory。
- Discord 是即时协作入口:适合快速提问、mention、群内讨论。
- Hermes 是通用 Agent gateway/runtime。
- CC Connect 是 Claude Code/项目代码执行入口。
- Codex 是 coding runtime,可处理仓库修改、测试、报告、PR。
- Agent Router 负责事件归一化、权限、限频、上下文装配、结果回写。
3. Discord 真正要怎么接
如果只是通知 Discourse 到 Discord
步骤:
- 在 Discord server 创建一个 channel,例如
#agent-community-updates。
- 在 Discord channel settings 里创建 Incoming Webhook。
- 在 Discourse 启用 chat integration:
chat_integration_enabled = true
chat_integration_discord_enabled = true
- 配规则:哪些 category/tag/topic event 推送到哪个 Discord webhook。
- 验证:发一个 Discourse topic,看 Discord 是否收到摘要。
这一步的 secret 是 Discord webhook URL,不能写到帖子或仓库里。
如果要让 Discord 里能 @ Agent
步骤:
- 在 Discord Developer Portal 创建 Application。
- 创建 Bot,拿 bot token。
- 启用 Gateway intents:
- Message Content Intent:需要读消息内容。
- Server Members Intent:Hermes 文档建议启用,用于成员/用户名解析和角色授权。
- 用 OAuth2 invite URL 安装到 server:
- scopes:
bot, applications.commands
- permissions: View Channels, Send Messages, Read Message History, Send Messages in Threads, Attach Files, Add Reactions 等。
- 选择 runtime:
- 如果想让 Hermes 成为 Discord bot:配置
DISCORD_BOT_TOKEN、DISCORD_ALLOWED_USERS 或 DISCORD_ALLOWED_ROLES,启动 hermes gateway。
- 如果想让 Claude Code 通过 Discord 跑项目:在 cc-connect
config.toml 里加 [[projects.platforms]] type = "discord"。
- 配 channel 策略:
- 普通频道默认 require mention。
- 专门 bot-help 频道可以设 free-response。
- coding 任务最好开 thread/session isolation。
- 验证:在 Discord 里 mention bot,看是否能收到回复。
如果要和 Discourse 双向联动
不建议一开始就做“完整双向同步所有消息”。更合理的是先做事件级联动:
- Discord 里
/new-topic 或 @agent create-topic → 创建 Discourse topic。
- Discord thread 里产生结论 → Router 摘要后回写 Discourse topic。
- Discourse topic 里 mention Agent → Router 调 Hermes/CC Connect/Codex 执行。
- Agent 执行结果 → 同时回 Discourse topic 和 Discord thread。
- 最终 decision → 写入 ChatBoard / Blog / Git。
这样 Discourse 仍然是长期记录,Discord 是实时入口,不会出现两个地方各有一份长 thread 难以合并的问题。
4. 推荐的最小实现顺序
M1:Discourse → Discord 通知
用 Discourse chat-integration 或一个轻量 webhook service,把新 topic / selected category / selected tag 推到 Discord。
验证标准:
- Discourse 发 topic。
- Discord channel 收到标题、摘要、链接。
M2:Hermes Discord bot 单独跑通
让 Hermes 作为 Discord bot 工作。
验证标准:
- DM 可问答。
- Server channel 里
@Hermes 才回复。
- Thread 里能保持 session。
- allowed users/roles 生效。
M3:CC Connect Discord coding 入口跑通
给某个项目配置 cc-connect Discord platform。
验证标准:
- Discord 里发 coding request。
- Claude Code/Codex-like runtime 能读项目、执行命令、给进度和最终答复。
- thread isolation 生效。
M4:Agent Router 统一 Discourse + Discord
实现一个小 Router:
- 输入:Discourse webhook + Discord bot event。
- 路由:按 mention/tag/category/channel/role 判断 agent。
- 执行:调用 Hermes/Codex/CC Connect。
- 输出:回 Discourse topic 和 Discord thread。
验证标准:
- Discourse
@researcher 能触发研究 Agent。
- Discord
@researcher 能创建/关联 Discourse topic。
- Agent 结果被写回 canonical topic。
5. 我现在的产品判断
Discord 不应该替代 Discourse。
- Discord 强在实时、轻量、社区氛围、语音/即时互动。
- Discourse 强在结构化 topic、长讨论、搜索、链接、SEO、decision log。
- Hermes/CC Connect 强在接 Agent runtime。
- Agent Router 强在统一事件、权限、审批和产物沉淀。
所以更好的产品形态是:
Discord = fast chat / mention surface
Discourse = canonical discussion and task memory
Agent Router = brainstem / event routing
Hermes + Codex + CC Connect = execution muscles
ChatBoard / Git / Blog = durable artifacts
6. 风险和边界
- Discord bot token 和 webhook URL 都是 secret,不能写进帖子、Git 或公开文档。
- Message Content Intent 是敏感能力,只应该给可信 bot,并限制 server/channel/role。
- Bot 默认应该 require mention,不要在所有频道里 free-response。
- 多 bot 同一个 thread 时要小心:最好启用 thread-level mention requirement 或 router 仲裁,避免多个 bot 同时回复。
- 写仓库、开 PR、部署、发外部消息、读 secret 等动作必须有人类审批。
- Discord 2000 字符限制需要自动拆分或用附件/链接承载长报告。
7. 下一步可执行任务
如果继续做,我建议开一个单独 task:
07-28-discord-agent-entry-prototype
范围只做两件事:
- 跑通 Hermes Discord bot 或 cc-connect Discord platform 中的一条。
- 做一个最小 Discourse ↔ Discord 关联:Discord 里发
/new-topic 或 @agent summarize-to-discourse,能创建/回写一个 Discourse topic。
这样我们就能从“静态调研”进入“真的从 Discord @ 一个 Agent,然后结果回到 Discourse topic”的验证。