Free Guide — From 14 Days of Real Building
How to Connect AI Agents to Discord
With Two-Way Communication
That Actually Works
The complete setup guide — plus the critical bug we discovered at 4 AM that broke everything. Based on real experience building an 11-agent AI team.
v1.0 | March 2026 | 15 min read
by AZ ROLLIN — @AZ_Rollin everywhere
SECTION 01
The Story — Why I Built This
And why you should too
Two weeks ago, I didn't know what a terminal was. I'm 38, I drive Uber, and I had zero coding experience. Then I started building with AI.
In 14 days, I built a team of 11 AI agents — a researcher, a writer, a finance analyst, a social media strategist, a content scorer, and more. They all live in Discord. They talk to each other. They cost $0.30 a day.
My main AI brain (Claude Code, running in my terminal) sends them tasks. They deliver. The system works.
Or at least, I thought it worked.
At 4 AM on March 5th, I discovered that my AI brain could send messages to the team — but couldn't hear a single response. The team had been delivering work for hours. Nobody was listening.
This guide is everything I learned building this system, including the critical bug and the 10-minute fix. Whether you're using Claude Code, ChatGPT, or any AI tool — if you want to build a team of agents on Discord, this will save you days of trial and error.
SECTION 02
The Architecture — How It All Connects
The big picture before we dive into steps
The Complete System
YOU
→
AI Brain
(Claude Code / ChatGPT / any terminal AI)
├── Webhooks → sends tasks to Discord
├── Listener → reads responses from Discord
└── Inbox file → stores everything the team says
DISCORD SERVER
├── #channel-per-agent (research, content, finance, etc.)
└── AI Bot → routes messages to the right agent
AGENT PLATFORM
(OpenClaw / custom / any multi-agent framework)
├── Agent 1 — Manager (delegates tasks)
├── Agent 2 — Researcher
├── Agent 3 — Writer
└── ... (as many as you need)
The key components:
- Discord Server — your team's workspace. Each agent gets a channel.
- Agent Platform — runs the AI agents. We used OpenClaw (open-source, free), but this works with any framework.
- Discord Bot — connects the agent platform to Discord. Routes messages to the right agent.
- Webhooks — let your main AI brain SEND messages to any channel.
- Listener — lets your main AI brain READ messages from all channels. This is the part everyone misses.
SECTION 03
Step 1 — Set Up Your Discord Server
5 minutes — create the workspace
A
Create a new Discord server
Open Discord → click the "+" button on the left → "Create My Own" → "For me and my friends" → name it whatever you want (I called mine "AZ Command Center").
B
Create channels for each agent role
Don't create channels for agent names — create them for functions. This way you can swap agents without renaming channels.
Recommended channels:
- #general — team-wide announcements, cross-functional tasks
- #research — market research, competitor analysis, data gathering
- #content — writing, scripts, outlines, copy
- #finance — cost tracking, pricing, budgets
- #social — posting strategy, hashtags, timing
- #dev — code, technical tasks, building
- #priorities — urgent tasks, daily priorities
- #support — operational support, monitoring
Start with 4-6 channels. You can always add more later.
C
Create webhooks for each channel
For each channel: Channel Settings → Integrations → Webhooks → New Webhook.
Name it something like "AI Brain" or "Claude Code". Copy the webhook URL and save it somewhere safe. You'll need these URLs later.
json
{
"general": "https://discord.com/api/webhooks/YOUR_ID/YOUR_TOKEN",
"research": "https://discord.com/api/webhooks/YOUR_ID/YOUR_TOKEN",
"content": "https://discord.com/api/webhooks/YOUR_ID/YOUR_TOKEN",
"finance": "https://discord.com/api/webhooks/YOUR_ID/YOUR_TOKEN"
}
Security Warning
Webhook URLs contain a secret token. Anyone with this URL can post to your channel. Keep them in a secure file with restricted permissions (chmod 600 on Mac/Linux).
SECTION 04
Step 2 — Install an AI Agent Platform
Set up the brains behind your agents
You need something that runs your AI agents and connects them to Discord. There are several options:
1
OpenClaw (what we used — open-source, free)
OpenClaw runs as a Docker container on your computer. It gives each agent a personality, a workspace, and routes messages from Discord to the right agent.
bash
git clone https://github.com/open-claw/open-claw.git
cd open-claw
docker compose up -d openclaw-gateway
Cost: The platform is free. You pay for the AI model your agents use. We use DeepSeek V3 API at ~$0.30/day for 11 agents.
- CrewAI — Python framework for multi-agent systems
- AutoGen — Microsoft's multi-agent framework
- Custom bot — Build your own Discord bot with discord.py or discord.js
- n8n / Make.com — No-code automation (simpler but less powerful)
The webhook + listener pattern in this guide works with any of these. The sending and receiving infrastructure is platform-agnostic.
Gotcha: Model Choice Matters
We wasted 2 days trying to use a free local model (Llama 3.1 8B). It was too dumb for agent work — returned raw JSON, couldn't follow instructions, broke tool calls. Switched to DeepSeek V3 at $0.30/day and everything instantly worked. Don't be cheap on the model. Be cheap on everything else.
SECTION 05
Step 3 — Connect Your AI to Discord (Sending)
The easy part — most people stop here. Don't.
Sending messages from your AI brain to Discord is straightforward using webhooks:
bash
curl -s -X POST "YOUR_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"content": "Hey team, here is your task...",
"username": "AI Brain"
}'
That's it. Replace YOUR_WEBHOOK_URL with the URL you saved in Step 1. The message appears in Discord as "AI Brain" (or whatever username you set).
Sending from Claude Code / any terminal AI
If you're using Claude Code or any AI that can run terminal commands, it can send to Discord directly:
example
You: "Send SCOUT a research task about competitor pricing"
AI:
"Task sent to #research channel. SCOUT will pick it up."
Gotcha: Discord 2000 Character Limit
Discord messages max out at 2,000 characters. If your AI sends a long task, it'll fail silently. Split long messages into parts, or have your AI chunk them automatically.
Gotcha: Bot Self-Ignore
If your agent platform's Discord bot and your webhook both use the same bot token, the bot might ignore webhook messages (it thinks it sent them itself). Webhooks create a separate author ID, which usually avoids this — but some platforms have additional filters. Test this explicitly.
Checkpoint
At this point, you can send tasks to Discord. Your agents receive them and respond. It looks like everything works. This is where 99% of guides stop.
But there's a massive problem hiding in plain sight.
SECTION 06
Step 4 — The Part Everyone Misses
Can your AI actually HEAR the responses?
Here's the question nobody asks:
"When your agents finish a task and respond in Discord... does your AI brain actually see it?"
If you're using webhooks to send messages, the answer is almost certainly no.
Webhooks are one-way. They can push messages into a channel. They cannot read messages from a channel. Your AI has a mouth but no ears.
The Broken Loop — What's Actually Happening
AI Brain
→ sends →
Discord
→
Agents
Agents
→ respond →
Discord
→ ✕ →
AI Brain
CAN'T HEAR
Your agents deliver work. Your AI never sees it. You only find out if you manually check Discord.
This is exactly what happened to us. We had 11 agents. 12 Discord channels. A manager that delegated tasks. Agent-to-agent communication that passed stress tests. Everything looked perfect.
Then at 4 AM, I casually asked my AI: "Did you see MAYA's message?" And it said: "No. I can't see Discord messages."
MAYA had finished a complete analysis hours earlier. Tagged the AI brain. The message sat there. Nobody was listening.
SECTION 07
The Broken Loop — What Went Wrong at 4 AM
The most dangerous bugs are the ones where nothing visibly breaks
Here's why this bug is so insidious: everything appears to work.
- You send a task → it appears in Discord. Check.
- Your agent responds → the response appears in Discord. Check.
- Your agent tags your AI brain → the tag appears in Discord. Check.
- Your AI brain sees the response → FAIL. Silent fail. No error. No warning.
You'd never know unless you specifically asked "did you see that?" And if you don't ask... the work piles up unseen. Your agents do their jobs. Your AI brain never gets the results. You become the manual relay — the exact thing you were trying to automate.
The Lesson
"Building a system that can talk but can't listen
is like hiring a team and never checking your email."
Always test the full loop. Not just "can I send?" but "does the response come back to where it needs to go?"
SECTION 08
Step 5 — Build the Listener (The Fix)
Close the loop — 10 minutes, zero dependencies
The fix is simple: a script that polls Discord channels and writes new messages to a file your AI brain reads.
How it works
- Script runs in the background, polls all channels every 30 seconds
- Uses the Discord REST API (same bot token your agent platform uses — no conflicts)
- Tracks the last message it saw per channel (no duplicates)
- Writes new messages to an "inbox" file
- Flags messages that mention your AI brain or come from you
- Your AI reads the inbox at the start of every session
python — discord_listener.py
import json, os, time, urllib.request
BOT_TOKEN = "your_bot_token"
INBOX_FILE = "discord-inbox.md"
POLL_INTERVAL = 30
STATE_FILE = ".listener-state.json"
CHANNELS = {
"general": "123456789",
"research": "123456790",
"content": "123456791",
}
def fetch_messages(channel_id, after_id):
"""Fetch messages after a given ID from Discord API."""
url = f"https://discord.com/api/v10/channels/{channel_id}/messages?limit=10"
if after_id:
url += f"&after={after_id}"
req = urllib.request.Request(url, headers={
"Authorization": f"Bot {BOT_TOKEN}"
})
with urllib.request.urlopen(req) as resp:
return list(reversed(json.loads(resp.read())))
def run():
state = json.load(open(STATE_FILE)) if os.path.exists(STATE_FILE) else {}
while True:
for name, ch_id in CHANNELS.items():
messages = fetch_messages(ch_id, state.get(ch_id))
for msg in messages:
author = msg["author"]["username"]
content = msg["content"]
timestamp = msg["timestamp"][:19]
with open(INBOX_FILE, "a") as f:
f.write(f"### [{timestamp}] #{name}\n")
f.write(f"**{author}:** {content}\n\n")
state[ch_id] = msg["id"]
time.sleep(0.3)
json.dump(state, open(STATE_FILE, "w"))
time.sleep(POLL_INTERVAL)
run()
This is the simplified version. The full version (included with this guide) adds:
- [MENTIONS YOU] flags on messages that tag your AI
- [FROM YOU] flags on your own messages
- Rate limit handling (Discord limits API calls)
- Error recovery (keeps running even if a request fails)
- State persistence (survives restarts, no duplicate messages)
- First-run initialization (doesn't dump old history)
bash
python3 discord_listener.py &
After The Fix — Full Two-Way Communication
AI Brain
→ webhooks →
Discord
→
Agents
Agents
→ respond →
Discord
→ listener →
AI Brain
NOW HEARS
Full duplex. Send tasks. Hear results. No human relay needed.
SECTION 09
7 Gotchas From 14 Days of Building
Real problems. Real fixes. Save yourself the pain.
1. Free Local Models Are Too Dumb for Agent Work
Llama 3.1 8B couldn't handle tool calls, returned raw JSON, broke constantly. Models under 70B parameters struggle with agent orchestration. Use an API model (DeepSeek V3 at $0.30/day is the sweet spot) and save local models for simple tasks.
2. Discord Messages Have a 2,000 Character Limit
Long tasks sent via webhook will silently fail. Your AI needs to chunk messages automatically. Always check the response from the webhook POST — a 400 error means the message was too long.
3. API Keys Will Leak If You're Not Careful
We almost leaked our Telegram bot token through debug logs. At 4 AM. If you're running curl commands to test webhooks, the URLs contain secret tokens that show up in terminal history. Use config files with restricted permissions instead of pasting tokens into commands.
4. Interrupting AI Mid-Task = Dropped Threads
We found 18 tasks that were started but never finished because the AI was redirected mid-work. If your AI is building something and you give it a new task, the old one dies silently. Let tasks finish before starting new ones, or use a task queue.
5. Bot Self-Message Filtering
Many Discord bot frameworks ignore messages from bots (including themselves) to prevent infinite loops. If your AI sends via the bot API instead of webhooks, the bot might ignore its own messages. Webhooks use a separate author ID, which usually works — but test it.
6. Rate Limits Are Real
Discord rate-limits API calls. If you poll too fast or send too many messages, you'll get 429 errors and temporary bans. The listener should wait 0.3-0.5 seconds between channel checks and handle 429s gracefully with retry-after delays.
7. The Broken Loop (This Entire Guide Exists Because of This)
Webhooks = send only. REST API = read only. You need BOTH for two-way communication. If you only set up webhooks, you have a megaphone — not a telephone. Always test the full loop: send a task, wait for the response, verify your AI actually received it.
SECTION 10
Launch Checklist
Verify everything before trusting the system
Discord Server
- Server created with functional channels (not agent-named)
- Webhooks created for each channel, URLs saved securely
- Webhook URL file has restricted permissions (chmod 600)
Agent Platform
- Platform installed and running (Docker, Python, etc.)
- Discord bot connected to server with correct permissions
- At least one agent registered and responding
- Agent-to-agent communication tested (if using multiple agents)
- API model selected and working (not a too-small local model)
Sending (Webhooks)
- Can send a message to at least one channel via webhook
- Message appears in Discord with correct username
- Agent responds to the webhook message (not filtered)
- Messages under 2,000 characters (or auto-chunked)
Receiving (Listener) — THE CRITICAL CHECK
- Listener script running in background
- State file created with all channel IDs tracked
- Send a test message → wait 30 seconds → verify it appears in inbox file
- Messages flagged correctly (mentions, your messages)
- AI reads inbox at session start
- Listener survives errors without crashing
- Listener added to auto-start script
Full Loop Test
- Send a task via webhook → agent responds → listener catches response → AI reads inbox → AI knows the result
- THIS is the test that matters. If this works, you're done.
Built By Someone Who Learned the Hard Way
I'm AZ. 38 years old. Zero coding experience before February 2026. I built an 11-agent AI team for $0.30/day and documented every mistake along the way.
If this guide helped you — follow the journey. I'm proving that anyone can build with AI, starting from absolute zero.
"I don't know what I'm doing. But I'm doing it anyway. Follow along."