How to Set Up Multiple OpenClaw Agents on Telegram (Step-by-Step)

What You'll Build
By the end of this tutorial, you'll have:
✅ 3 Telegram bots (Marketing, DevOps, Support)
✅ Each bot connected to a distinct OpenClaw agent
✅ Cross-agent communication (agents can invoke each other)
✅ Shared memory across all agents
✅ Production-ready setup with logging and monitoring
Time required: 30-45 minutes
Prerequisites
Before starting, ensure you have:
- OpenClaw installed (Installation guide)
- A Telegram account
- Basic terminal/command-line knowledge
- Node.js 18+ (for OpenClaw)
- A server or local machine where OpenClaw can run 24/7
Step 1: Create Telegram Bots via BotFather
Telegram uses BotFather to manage bots. You'll create 3 bots, one for each agent.
1.1 Open BotFather
- Open Telegram
- Search for
@BotFather(official Telegram bot) - Start a chat:
/start
1.2 Create Your First Bot (Marketing Agent)
Send: /newbot
BotFather will ask:
Alright, a new bot. How are we going to call it?
Please choose a name for your bot.
You reply: Marketing Agent
BotFather:
Good. Now let's choose a username for your bot.
It must end in `bot`. Like this, for example: TetrisBot or tetris_bot.
You reply: marketing_agent_bot (must be unique across all Telegram)
BotFather responds:
Done! Congratulations on your new bot. You will find it at
t.me/marketing_agent_bot. You can now add a description...
Use this token to access the HTTP API:
1234567890:ABCdefGHIjklMNOpqrsTUVwxyz1234567890
For a description of the Bot API, see this page:
https://core.telegram.org/bots/api
Save this token! You'll need it for OpenClaw configuration.
1.3 Repeat for Other Agents
Create 2 more bots:
Bot 2: DevOps Agent
- Name:
DevOps Agent - Username:
devops_agent_bot - Token:
(save this)
Bot 3: Support Agent
- Name:
Support Agent - Username:
support_agent_bot - Token:
(save this)
Step 2: Set Up Bot Profiles (Optional but Recommended)
Make each bot recognizable with a description and profile picture.
2.1 Set Bot Description
Send to BotFather:
/setdescription
Choose bot: @marketing_agent_bot
Enter description:
I handle marketing strategy, content creation, and SEO for the team. Ask me about blog posts, social media, or campaigns.
Repeat for other bots with their respective descriptions.
2.2 Set Bot Profile Picture
Send to BotFather:
/setuserpic
Choose bot, then upload an image (PNG/JPG, square, 512x512 recommended).
2.3 Set Bot Commands (Auto-Complete Menu)
Send to BotFather:
/setcommands
Choose bot: @marketing_agent_bot
Enter commands:
status - Check agent status
help - Get help with marketing tasks
publish - Publish content
analytics - View marketing metrics
Users will see these commands when they type / in the bot chat.
Step 3: Configure OpenClaw Gateway
OpenClaw uses a central gateway to route messages between channels (Telegram, Discord, etc.) and agents.
3.1 Locate Your OpenClaw Config
OpenClaw config is typically at:
~/.openclaw/config.json
Or in your project directory if you're using a workspace-specific setup.
3.2 Add Telegram Channel Configurations
Edit config.json:
{
"channels": {
"telegram": {
"enabled": true,
"bots": [
{
"name": "marketing",
"token": "1234567890:ABCdefGHIjklMNOpqrsTUVwxyz1234567890",
"agent": "marketing-agent",
"description": "Marketing and content strategy"
},
{
"name": "devops",
"token": "0987654321:ZYXwvuTSRqponMLKjihGFEdcba0987654321",
"agent": "devops-agent",
"description": "Infrastructure and deployments"
},
{
"name": "support",
"token": "1122334455:AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRr",
"agent": "support-agent",
"description": "Customer support and issue triage"
}
]
}
}
}Key fields:
name— Internal identifier for this bot (lowercase, no spaces)token— Bot token from BotFatheragent— Name of the OpenClaw agent this bot routes todescription— Human-readable description (for logs/UI)
Step 4: Create OpenClaw Agent Configurations
Each Telegram bot needs a corresponding agent in OpenClaw.
4.1 Create Agent Directory Structure
mkdir -p ~/.openclaw/agents/marketing-agent
mkdir -p ~/.openclaw/agents/devops-agent
mkdir -p ~/.openclaw/agents/support-agent4.2 Define Agent Identity Files
Create ~/.openclaw/agents/marketing-agent/IDENTITY.md:
# Marketing Agent
- **Name:** Nadia
- **Role:** Marketing Strategist
- **Vibe:** Creative, data-driven, strategic
- **Emoji:** 📊
I handle content strategy, SEO, social media, and campaign planning.Create ~/.openclaw/agents/marketing-agent/SOUL.md:
# SOUL.md — Marketing Agent
You are Nadia, the marketing lead.
Your role:
- Content strategy and creation
- SEO optimization
- Social media management
- Campaign planning and execution
When users ask marketing questions, provide actionable insights.
When you need DevOps help (deployments, infrastructure), spawn a devops-agent session.Repeat this structure for devops-agent and support-agent with their own identities.
Step 5: Start the OpenClaw Gateway
5.1 Start the Gateway
openclaw gateway startExpected output:
✓ Gateway started on port 18799
✓ Telegram: Connected 3 bots
- marketing-agent → @marketing_agent_bot
- devops-agent → @devops_agent_bot
- support-agent → @support_agent_bot
✓ Ready to receive messages
5.2 Verify Bot Status
Open Telegram and message any of your bots:
/status
Expected response:
✅ Agent online
Name: Marketing Agent (Nadia)
Status: Active
Uptime: 2 minutes
Step 6: Test Cross-Agent Communication
Now let's test if agents can talk to each other.
6.1 Message the Marketing Bot
Send to @marketing_agent_bot:
Can you deploy the new blog post?
6.2 What Should Happen
- Marketing Agent receives your message
- Recognizes "deploy" = DevOps task
- Spawns a sub-agent session with DevOps Agent
- DevOps Agent handles deployment
- Marketing Agent replies:
✅ Blog post deployed to production.
Live at: https://example.com/blog/new-post
Deployment handled by DevOps Agent.
6.3 Check Gateway Logs
openclaw gateway logsYou should see:
[INFO] Telegram/marketing: User 123456789 → "Can you deploy the new blog post?"
[INFO] Agent marketing-agent: Spawning sub-agent devops-agent
[INFO] Agent devops-agent: Executing deployment task
[INFO] Agent devops-agent: Deployment complete
[INFO] Agent marketing-agent: Reply sent to user
Step 7: Configure Shared Memory
Agents should share context (conversation history, project state).
7.1 Enable Memory Sharing
Edit ~/.openclaw/config.json:
{
"memory": {
"enabled": true,
"backend": "file",
"path": "~/.openclaw/memory",
"shared": true
}
}7.2 Create Memory Files
mkdir -p ~/.openclaw/memory
touch ~/.openclaw/memory/MEMORY.mdAdd initial content to MEMORY.md:
# Shared Memory
## Team Context
- Organization: Noqta
- Mission: AI-powered development services
- Current project: Multi-agent Telegram setup
## Important Notes
- Marketing Agent handles content
- DevOps Agent handles infrastructure
- Support Agent handles client queriesNow all agents can read/write to this shared memory.
Step 8: Production Deployment
8.1 Run Gateway as a Service
Use PM2 (Node.js process manager):
npm install -g pm2
pm2 start openclaw --name "openclaw-gateway" -- gateway start
pm2 save
pm2 startupThis ensures the gateway restarts automatically on server reboot.
8.2 Set Up Monitoring
pm2 monitShows real-time CPU/memory usage, logs, and restarts.
8.3 Log Rotation
pm2 install pm2-logrotate
pm2 set pm2-logrotate:max_size 10M
pm2 set pm2-logrotate:retain 7Prevents logs from consuming disk space.
Step 9: Security Best Practices
9.1 Environment Variables for Tokens
Don't hardcode bot tokens in config.json.
Use environment variables:
{
"channels": {
"telegram": {
"bots": [
{
"name": "marketing",
"token": "${TELEGRAM_MARKETING_TOKEN}",
"agent": "marketing-agent"
}
]
}
}
}Set in your shell:
export TELEGRAM_MARKETING_TOKEN="1234567890:ABCdef..."
export TELEGRAM_DEVOPS_TOKEN="0987654321:ZYXwvu..."
export TELEGRAM_SUPPORT_TOKEN="1122334455:AaBbCc..."9.2 Restrict Bot Access
Use Telegram's allowed users feature:
Edit config.json:
{
"channels": {
"telegram": {
"bots": [
{
"name": "marketing",
"token": "${TELEGRAM_MARKETING_TOKEN}",
"agent": "marketing-agent",
"allowedUsers": [123456789, 987654321]
}
]
}
}
}Only users with those Telegram IDs can interact with the bot.
Troubleshooting
Problem: Bot doesn't respond
Check 1: Is the gateway running?
openclaw gateway statusCheck 2: Is the bot token correct?
Test manually:
curl https://api.telegram.org/bot<YOUR_TOKEN>/getMeShould return bot details.
Check 3: Check logs
openclaw gateway logs --tail 50Problem: Agents can't communicate
Check 1: Are all agents configured?
openclaw agents listCheck 2: Is memory sharing enabled?
Edit config.json:
{
"memory": {
"shared": true
}
}Check 3: Test sub-agent spawning manually
From within an agent:
sessions_spawn({
runtime: "subagent",
agentId: "devops-agent",
task: "Test task",
mode: "run"
})Problem: High memory usage
Solution: Limit session history
Edit agent AGENTS.md:
## Session Management
- Keep last 100 messages only
- Clear old sessions after 24 hoursNext Steps
Now that you have a working multi-agent Telegram setup:
✅ Add more agents (QA, Analytics, etc.)
✅ Customize agent personalities (edit SOUL.md)
✅ Build workflows (marketing → devops → QA pipelines)
✅ Monitor performance (track response times, success rates)
Resources
- OpenClaw Docs: https://docs.openclaw.ai
- Telegram Bot API: https://core.telegram.org/bots/api
- Community Discord: https://discord.com/invite/clawd
- GitHub: https://github.com/openclaw/openclaw
Need help? Book a consultation: /ai-automation
Discuss Your Project with Us
We're here to help with your web development needs. Schedule a call to discuss your project and how we can assist you.
Let's find the best solutions for your needs.
Related Articles

Creating a Custom Slackbot with NVIDIA NIM and LangChain
A comprehensive guide to building a custom Slackbot using NVIDIA NIM and LangChain, enhancing productivity and collaboration in modern business environments.

Guide to HeyGen Template API
A comprehensive guide to using HeyGen's Template API with JavaScript, including step-by-step instructions and code examples.

How to Open a Free Flouci Professional Account for Self-Employed Individuals in Tunisia
A step-by-step guide on how self-employed individuals and professionals in Tunisia can open a free Flouci Professional bank account.