OpenClaw Discord部署完整教學指南
把Discord變成你的AI工作團隊:每個頻道對應一個專屬AI Agent。從建立Discord Bot、安裝OpenClaw,到把Agent綁到指定頻道,給非工程師的步驟整理。
發布 2026/04/09・更新 2026/11/01
完成這份教學,你會有:
- 一個以Discord為介面的AI工作團隊
- 每個頻道對應一個專屬AI Agent
- 不需要寫程式,照步驟貼指令就好
初版:2026-04-09。2026-11-01依OpenClaw官方文件重新查證,第5、6步已改寫: 初版用
openclaw agents bind --bind discord:頻道ID把Agent綁到頻道,但現在官方文件寫明,冒號後面是Bot帳號代稱(accountId),不是頻道ID。要讓「一個頻道一個Agent」,改用設定檔裡的bindings(見第6步)。OpenClaw更新很快,指令以官方文件為準:https://docs.openclaw.ai
Step 1|建立Discord Bot
到 https://discord.com/developers/applications
- New Application → 輸入Bot名稱
- 左側選Bot
- Reset Token → 複製並安全保存(Token等於Bot的密碼,不要貼到公開地方)
- 開啟Message Content Intent和Server Members Intent
- OAuth2 → URL Generator → 勾選bot和Send Messages
- 複製邀請連結,把Bot加入你的伺服器
Step 2|取得伺服器ID和頻道ID
Discord → 使用者設定 → 進階 → 開啟開發者模式。
- 在伺服器名稱上按右鍵 → 複製伺服器ID
- 對每個要放Agent的頻道按右鍵 → 複製頻道ID
Step 3|安裝OpenClaw
需要先裝好Node.js。在終端機執行:
npm install -g openclaw
openclaw --version
Step 4|初始設定
官方文件現在的設定精靈是onboard(初版寫的openclaw setup是舊說法):
openclaw onboard
- 依提示選模型與登入方式
- 頻道選Discord,貼上Bot Token
- 其他不確定的先用預設值
Step 5|建立Agent
每個角色建一個Agent,名字可以自己取:
openclaw agents add trader
openclaw agents add content
openclaw agents add artist
openclaw agents add coder
openclaw agents add researcher
openclaw agents add sales
openclaw agents add blogger
每個Agent會有自己的工作資料夾和對話紀錄,彼此分開。
Step 6|把Agent綁到指定頻道
打開設定檔~/.openclaw/openclaw.json,在bindings裡每個頻道加一筆。下面是官方文件的寫法,把頻道ID換成Step 2複製的數字:
{
bindings: [
{
agentId: "trader",
match: {
channel: "discord",
accountId: "default",
peer: { kind: "channel", id: "你的頻道ID" },
},
},
{
agentId: "content",
match: {
channel: "discord",
accountId: "default",
peer: { kind: "channel", id: "另一個頻道ID" },
},
},
],
}
- 一個頻道一筆,其他Agent照樣複製
accountId: "default"代表你在Step 4設定的那一隻Bot- Discord頻道也要允許Bot回應:官方範例是在
channels.discord.accounts.default.guilds.伺服器ID.channels.頻道ID設enabled: true;細節看官方Discord頁面 https://docs.openclaw.ai/channels/discord
改完後套用並確認:
openclaw gateway restart
openclaw agents list --bindings
openclaw channels status --probe
Step 7|讓Gateway一直開著
Gateway是讓Bot在線上的背景程式。openclaw onboard可以幫你裝成背景服務;之後用下面這行看狀態:
openclaw gateway status
放在VPS上,關掉SSH連線後還要繼續跑,就要裝成背景服務。初版用nohup手動丟到背景的寫法也可以,但現在官方比較建議用背景服務。
Step 8|測試
到Discord對應的頻道傳訊息,該頻道的Agent會回應。
常見問題
- Bot沒回應: 先跑
openclaw channels status --probe和openclaw gateway status,再openclaw gateway restart。 - 訊息跑錯Agent或沒人接: 用
openclaw agents list --bindings檢查Step 6的頻道ID有沒有填對;官方有openclaw doctor可以檢查設定問題。 - 關掉SSH後就停了: 改成背景服務(Step 7)。
- Token失效: 到Discord Developer Portal重新Reset Token,再更新OpenClaw設定。
官方來源
- Agent綁定:https://docs.openclaw.ai/concepts/agent-bindings
- 多Agent路由:https://docs.openclaw.ai/concepts/multi-agent
openclaw agents指令:https://docs.openclaw.ai/cli/agents


