The real power of AI COMMS is running multiple AI agents that communicate with each other — and with humans — over WhatsApp.
Each agent is a separate running instance of AI COMMS with its own:
- Phone number (or WhatsApp-linked device)
- AI provider
- Identity (name + ID)
- Configuration
Agents message each other over WhatsApp using a structured JSON protocol. From WhatsApp's perspective, it's just two phone numbers texting each other. Under the hood, the messages are structured, authenticated, and encrypted.
┌──────────────┐ WhatsApp ┌──────────────┐
│ Agent: Atlas│◄───────────────────────►│ Agent: Nova │
│ Provider: │ Encrypted JSON Protocol│ Provider: │
│ OpenAI │ │ Anthropic │
│ Phone: +1.. │ │ Phone: +44.. │
└──────┬───────┘ └───────┬───────┘
│ │
│ ┌──────────────┐ │
└─────────►│ Agent: Bolt │◄───────────────┘
│ Provider: │
│ Groq │
│ Phone: +91..│
└──────────────┘
Machine A (or container 1), with phone number A:
# .env for Atlas
AI_PROVIDER=openai
OPENAI_API_KEY=sk-...
AGENT_NAME=Atlas
AGENT_ID=atlas_001
PLATFORM=whatsapp
WHATSAPP_MODE=baileys
SECURITY_REQUIRE_AGENT_AUTH=true
SECURITY_AGENT_SECRET=a]f8k2...your-shared-secret...m9x1z
SECURITY_ENCRYPTION_KEY=b7d3e...your-shared-key...4f2a8
HEALTH_PORT=9090npm start # scan QR with phone AMachine B (or container 2), with phone number B:
# .env for Nova
AI_PROVIDER=anthropic
ANTHROPIC_API_KEY=sk-ant-...
AGENT_NAME=Nova
AGENT_ID=nova_001
PLATFORM=whatsapp
WHATSAPP_MODE=baileys
SECURITY_REQUIRE_AGENT_AUTH=true
SECURITY_AGENT_SECRET=a]f8k2...your-shared-secret...m9x1z # SAME secret
SECURITY_ENCRYPTION_KEY=b7d3e...your-shared-key...4f2a8 # SAME key
HEALTH_PORT=9091npm start # scan QR with phone BAll agents in the network must have the same:
SECURITY_AGENT_SECRET— for HMAC authenticationSECURITY_ENCRYPTION_KEY— for payload encryption
Generate them once and copy to all agents:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"When Agent Atlas wants to talk to Agent Nova, it sends a structured JSON message over WhatsApp:
{
"protocol": "ai-comms",
"version": "1.0",
"from": {
"agentId": "atlas_001",
"agentName": "Atlas"
},
"to": {
"agentId": "nova_001",
"agentName": "Nova"
},
"intent": "chat",
"payload": "What's your analysis of the latest climate data?",
"conversationId": "conv_abc123",
"timestamp": "2026-04-04T12:00:00.000Z",
"auth": {
"hmac": "a1b2c3d4...",
"algorithm": "sha256"
}
}The receiving agent:
- Verifies the HMAC signature
- Checks the timestamp (replay protection)
- Decrypts the payload (if encrypted)
- Processes the message through its AI provider
- Sends a structured reply back
All of this happens automatically — you don't need to construct these messages manually.
When an agent starts, it can announce itself to the network. Other agents that receive the announcement automatically register it in their discovery registry.
- Agent Atlas sends a message to Agent Nova's phone number
- If the message contains an announcement intent, Nova registers Atlas in its local registry
- Nova responds with its own identity
From WhatsApp (as an admin):
!agents
Or via the discovery module in code:
import { listAgents } from './discovery.js';
const agents = listAgents();Groups let multiple agents (and humans) collaborate in a shared conversation.
Send a message to your agent via WhatsApp:
Create a research group with Atlas, Nova, and Bolt
The AI interprets this and creates a group. Behind the scenes, it executes:
{"command": "create-group", "name": "Research Team", "purpose": "Collaborative research"}Add the agent at +44... with name Nova to the Research Team group
Tell the Research Team: What are your thoughts on quantum error correction?
The agent broadcasts the message to all group members. Each member processes it with their own AI and responds.
When agents reply within a group, recent group messages are included as context so each agent knows what the others have said. This enables genuine multi-agent discussion.
!groups # list all groups
Each agent can have its own failover chain:
Agent Atlas:
AI_PROVIDER=openai
AI_FALLBACK_PROVIDERS=anthropic,groqAgent Nova:
AI_PROVIDER=anthropic
AI_FALLBACK_PROVIDERS=google,openaiIf Atlas's OpenAI goes down, it falls over to Anthropic, then Groq. Nova has its own independent chain. This gives the network resilience — even if a major provider has an outage, agents stay online.
A real-world setup using OpenClaw and NVIDIA NIM:
Agent: ClawHub (self-hosted via OpenClaw)
AI_PROVIDER=openclaw
OPENCLAW_BASE_URL=http://localhost:18789
OPENCLAW_AUTH_TOKEN=secret
AGENT_NAME=ClawHub
AGENT_ID=clawhub_001
AI_FALLBACK_PROVIDERS=nvidia-nim
NVIDIA_API_KEY=nvapi-...
SECURITY_REQUIRE_AGENT_AUTH=true
SECURITY_AGENT_SECRET=<shared>
SECURITY_ENCRYPTION_KEY=<shared>Agent: NemoClaw (NVIDIA NIM cloud)
AI_PROVIDER=nvidia-nim
NVIDIA_API_KEY=nvapi-...
AGENT_NAME=NemoClaw
AGENT_ID=nemoclaw_001
AI_FALLBACK_PROVIDERS=groq,anthropic
GROQ_API_KEY=gsk_...
ANTHROPIC_API_KEY=sk-ant-...
SECURITY_REQUIRE_AGENT_AUTH=true
SECURITY_AGENT_SECRET=<shared>
SECURITY_ENCRYPTION_KEY=<shared>ClawHub handles personal tasks through your private OpenClaw gateway. NemoClaw handles heavy reasoning via NVIDIA. If OpenClaw goes down, ClawHub automatically fails over to NemoClaw's NVIDIA endpoint.
Run multiple agents on one machine:
version: '3.8'
services:
atlas:
build: .
env_file: .env.atlas
volumes:
- ./auth_atlas:/app/auth_info
- ./data_atlas:/app/data
ports:
- "9090:9090"
nova:
build: .
env_file: .env.nova
volumes:
- ./auth_nova:/app/auth_info
- ./data_nova:/app/data
ports:
- "9091:9090"
bolt:
build: .
env_file: .env.bolt
volumes:
- ./auth_bolt:/app/auth_info
- ./data_bolt:/app/data
ports:
- "9092:9090"Each agent gets its own auth directory, data directory, and health port.
- One phone number per agent — each Baileys instance needs its own WhatsApp-linked device
- Unique AGENT_ID — every agent must have a distinct ID
- Unique HEALTH_PORT — if running on the same host, set different ports
- Shared secrets — all agents need the same
SECURITY_AGENT_SECRETandSECURITY_ENCRYPTION_KEY - Separate data directories — mount different volumes for
auth_info/anddata/
Human sends "Research quantum error correction" to Atlas on WhatsApp
│
▼
┌─ Atlas ──────────────────────────────────────────────┐
│ 1. Security gate (allowlist, rate limit) │
│ 2. Jailbreak defense (pattern check, escalation) │
│ 3. AI processing (OpenAI GPT-4o) │
│ 4. AI decides to broadcast to Research Team group │
│ 5. Creates signed + encrypted agent messages │
│ 6. Sends to Nova and Bolt via WhatsApp │
└──────────────────────────────────────────────────────┘
│ │
▼ ▼
┌─ Nova ───────────────┐ ┌─ Bolt ───────────────┐
│ 1. Verify HMAC sig │ │ 1. Verify HMAC sig │
│ 2. Decrypt payload │ │ 2. Decrypt payload │
│ 3. Check timestamp │ │ 3. Check timestamp │
│ 4. AI processing │ │ 4. AI processing │
│ (Anthropic) │ │ (Groq) │
│ 5. Reply to group │ │ 5. Reply to group │
└──────────────────────┘ └──────────────────────┘
│ │
▼ ▼
Atlas receives both replies, includes them in group context
│
▼
Human sees the collaborative response on WhatsApp
For production networks where agents run on different machines, use the Agent Hub — a WebSocket relay server that handles agent registration, discovery, task routing, and heartbeat monitoring.
- No port forwarding — agents connect outbound to the hub
- Dynamic discovery — agents register on connect, no manual registry needed
- Heartbeat monitoring — dead agents are automatically removed (90s timeout)
- REST API — query agents, send tasks, and broadcast from your bot without WebSocket code
# Local development
npm run hub
# Production
HUB_SECRET=your-shared-secret PORT=8090 node hub/server.js| Variable | Default | Description |
|---|---|---|
PORT |
8090 |
Listen port |
HUB_SECRET |
(none) | Shared secret for agent auth (required in production) |
HUB_MAX_AGENTS |
50 |
Max concurrent agent connections |
HUB_LOG_LEVEL |
info |
debug, info, warn, or error |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
GET |
/health |
No | Hub status + agent count |
GET |
/agents |
Yes | List all connected agents |
POST |
/task |
Yes | Send a task to a named agent |
POST |
/broadcast |
Yes | Send a task to all agents |
Authentication: Authorization: Bearer <HUB_SECRET>
curl -X POST http://hub.yoursite.com:8090/task \
-H "Authorization: Bearer your-secret" \
-H "Content-Type: application/json" \
-d '{"agent": "network-ai", "message": "list running processes", "sender": "admin"}'curl -X POST http://hub.yoursite.com:8090/broadcast \
-H "Authorization: Bearer your-secret" \
-H "Content-Type: application/json" \
-d '{"message": "status check", "sender": "admin"}'Connect your bot to the hub instead of direct HTTP:
# .env
AGENT_HUB_URL=http://hub.yoursite.com:8090
AGENT_HUB_SECRET=your-shared-secretWhen AGENT_HUB_URL is set, the multi-agent coordinator automatically:
- Discovers agents via the hub REST API (no manual registry needed)
- Routes
!teamtasks through the hub - Shows hub status in
!agentsoutput
Agents connect to the hub via WebSocket and register:
{
"type": "register",
"name": "network-ai",
"workspace": "ai-comms",
"skills": ["networking", "automation"],
"secret": "your-shared-secret"
}The hub assigns a UUID and broadcasts agent-joined events to all other agents. Tasks are routed by agent name, and responses flow back through the hub.
Agent conversations are automatically purged after 24 hours of inactivity to prevent unbounded memory growth. This applies to both human and agent conversations.
Active conversations are kept in memory and persisted to data/conversations.json. Stale entries are cleaned up every 30 minutes.
Next: Back to README →