How to Deploy an AI Agent on Telegram (Step-by-Step, 2026)
Your own AI agent running on Telegram, responding to messages 24/7. Create a bot, wire it to OpenClaw, give it a personality with SOUL.md, and let it handle conversations while you sleep. No coding required.
Why Telegram for Your AI Agent?
Telegram is the best platform for running a personal AI agent. It is free, has no rate limits for bots, works on every device, supports rich formatting, and gives you push notifications on your phone. No web dashboard to check. No app to build. Just open Telegram and talk to your agent.
With OpenClaw, you can deploy a fully autonomous AI agent on Telegram in under 10 minutes. Your agent gets its own personality, rules, and skills defined in a single SOUL.md file. It can answer questions, run tasks, search the web, summarize documents, and anything else you configure it to do.
What You Need Before Starting
Node.js 22 or later — Required to run OpenClaw. Download from nodejs.org or install via your package manager.
OpenClaw installed — Run npm install -g openclaw to install globally.
A Telegram account — Any free Telegram account works. You will use it to create a bot via BotFather.
An API key (Anthropic, OpenAI, or Google) — For your agent’s AI model. Anthropic Claude is recommended for best quality.
Step 1: Create a Telegram Bot with BotFather
Every Telegram bot starts with BotFather. Open Telegram, search for @BotFather, and create your bot in under a minute.
# 1. Open Telegram and search for @BotFather
# 2. Send /newbot
# 3. Choose a display name (e.g., "My AI Assistant")
# 4. Choose a username ending in "bot" (e.g., "myai_assistant_bot")
# 5. BotFather gives you a token like:
# 7123456789:AAHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#
# Save this token — you will need it in Step 2.
# Optional: customize your bot
# /setdescription — set what users see before starting a chat
# /setabouttext — set the bio shown in the bot profile
# /setuserpic — upload an avatar for your botYour bot token is like a password. Do not share it publicly or commit it to a repository. Anyone with the token can control your bot.
Step 2: Configure OpenClaw with Your Telegram Token
Now connect OpenClaw to your Telegram bot. This tells OpenClaw where to listen for messages and where to send responses.
# Initialize OpenClaw (skip if already done)
openclaw init
# Set your AI model provider
openclaw models auth paste-token --provider anthropic
# Paste your Anthropic API key when prompted
# Set your Telegram bot token
openclaw config set telegram.token 7123456789:AAHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Set your Telegram chat ID (your personal chat)
# To find your chat ID:
# 1. Message your bot on Telegram
# 2. Visit: https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates
# 3. Look for "chat":{"id": 123456789}
openclaw config set telegram.chatId 123456789Tip: If you do not see any updates when visiting the getUpdates URL, send a message to your bot first, then refresh. Telegram only shows updates after someone interacts with the bot.
Step 3: Create Your Agent’s SOUL.md
The SOUL.md file defines who your agent is, what it can do, and how it behaves. Think of it as your agent’s personality and instruction manual in one file.
Here is an example SOUL.md for a personal assistant agent on Telegram:
# Create a workspace for your agent
mkdir -p ~/agents/assistant
cd ~/agents/assistant
# Create the SOUL.md file
cat > SOUL.md << 'EOF'
# Personal Assistant
## Identity
You are a personal AI assistant on Telegram.
You help with tasks, answer questions, and keep things organized.
## Rules
- Be concise. Telegram messages should be short and scannable.
- Use bullet points for lists.
- When asked to remind, confirm the time and topic.
- Never share personal data outside this chat.
- If unsure, say so. Do not make things up.
## Skills
- quick-answer: Answer factual questions clearly and briefly
- summarize: Condense long text into key bullet points
- brainstorm: Generate ideas on any topic
- draft: Write emails, messages, or short documents
- explain: Break down complex topics in simple terms
## Tone
Friendly but efficient. No filler. Get to the point.
Use casual language, not corporate speak.
EOF
# Register the agent with OpenClaw
openclaw agents add assistant --workspace ~/agents/assistant --non-interactiveTip: The CrewClaw Generator has 20+ pre-built SOUL.md templates for roles like DevOps, Content Writer, SEO Analyst, and more. Pick a role, customize, and download. Try it free →
Step 4: Start Your Agent
With the bot token configured and SOUL.md in place, start OpenClaw and your agent goes live on Telegram immediately.
# Start the OpenClaw gateway
openclaw gateway start
# Your agent is now live on Telegram.
# Open Telegram, find your bot, and send a message.
# Test it:
# You: "What can you help me with?"
# Agent: responds based on your SOUL.md configuration
# To test from the command line instead:
openclaw agent --agent assistant --message "Hello, what can you do?"
# Check logs if something is not working:
openclaw gateway logsThe gateway runs on port 18789 by default. As long as the gateway is running, your Telegram bot is active and responding to messages.
Step 5: Run Your Agent 24/7
Your agent is only useful if it is always on. Here is how to keep it running permanently on Mac, Raspberry Pi or Linux VPS, and Docker.
Option A: launchd on Mac
# Create a launchd plist
cat > ~/Library/LaunchAgents/com.openclaw.gateway.plist << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.openclaw.gateway</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/openclaw</string>
<string>gateway</string>
<string>start</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/openclaw.log</string>
<key>StandardErrorPath</key>
<string>/tmp/openclaw-error.log</string>
</dict>
</plist>
EOF
# Load the service
launchctl load ~/Library/LaunchAgents/com.openclaw.gateway.plist
# Check it is running
launchctl list | grep openclawOption B: systemd on Raspberry Pi or VPS
# Create a systemd service file
sudo tee /etc/systemd/system/openclaw.service << 'EOF'
[Unit]
Description=OpenClaw AI Agent Gateway
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi
ExecStart=/usr/bin/openclaw gateway start
Restart=always
RestartSec=10
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
EOF
# Enable and start
sudo systemctl enable openclaw
sudo systemctl start openclaw
# Check status
sudo systemctl status openclaw
# View logs
journalctl -u openclaw -fOption C: Docker
# Create a Dockerfile
cat > Dockerfile << 'EOF'
FROM node:22-slim
RUN npm install -g openclaw
WORKDIR /app
COPY agents/ ./agents/
CMD ["openclaw", "gateway", "start"]
EOF
# Build and run
docker build -t openclaw-telegram .
docker run -d \
--name openclaw-agent \
--restart unless-stopped \
-e ANTHROPIC_API_KEY=your-key-here \
openclaw-telegram
# Check logs
docker logs -f openclaw-agentAll three options auto-restart your agent after crashes or reboots. Pick the one that matches your setup. Mac users: use launchd. Linux/Pi users: use systemd. Docker fans: use Docker.
Advanced: Multiple Agents on Telegram
You can run multiple AI agents on Telegram from the same OpenClaw installation. Each agent gets its own Telegram bot and its own SOUL.md.
# Create separate workspaces for each agent
mkdir -p ~/agents/writer ~/agents/researcher ~/agents/monitor
# Each agent has its own SOUL.md
# ~/agents/writer/SOUL.md — drafts content
# ~/agents/researcher/SOUL.md — answers research questions
# ~/agents/monitor/SOUL.md — monitors servers and alerts
# Register each agent
openclaw agents add writer --workspace ~/agents/writer --non-interactive
openclaw agents add researcher --workspace ~/agents/researcher --non-interactive
openclaw agents add monitor --workspace ~/agents/monitor --non-interactive
# Create a Telegram bot for each agent via @BotFather
# Each bot gets its own token
# Configure routing in OpenClaw
# The gateway routes messages from each bot to the correct agent
openclaw config set agents.writer.telegram.token BOT_TOKEN_1
openclaw config set agents.researcher.telegram.token BOT_TOKEN_2
openclaw config set agents.monitor.telegram.token BOT_TOKEN_3
# Start the gateway — all agents go live
openclaw gateway startWriter Bot
Drafts blog posts, emails, and social media content on demand.
Researcher Bot
Answers questions with detailed explanations and sources.
Monitor Bot
Watches servers, sends alerts when something breaks.
Troubleshooting Common Issues
Bot does not respond to messages. Check that the gateway is running with openclaw gateway status. Verify the bot token is correct with openclaw config get telegram.token. Make sure you sent a message to the bot first (Telegram does not deliver messages until the user initiates).
“Unauthorized” error in logs. Your bot token is invalid or expired. Go back to @BotFather, revoke the old token with /revoke, create a new one, and update it with openclaw config set telegram.token NEW_TOKEN.
Agent responds but very slowly. This is usually the AI model, not Telegram. Check your API provider’s status page. Try switching to a faster model temporarily. Claude Haiku or GPT-4o Mini are fast options for quick responses.
Chat ID not found. If getUpdates returns an empty array, send any message to your bot on Telegram, then visit the getUpdates URL again. The chat ID appears under message.chat.id in the JSON response.
Agent loses context between messages. OpenClaw persists sessions by default. If context is lost, check that your agent workspace directory is writable and that the sessions folder exists. Run ls ~/.openclaw/agents/assistant/sessions/ to verify.
Related Guides
Frequently Asked Questions
Is the Telegram bot free to create?
Yes. Telegram bots are completely free to create and run. You create them through BotFather, which is Telegram's official bot management tool. There are no fees, no rate limits for moderate usage, and no approval process. You get a bot token instantly and can start receiving messages right away.
Can my Telegram AI agent handle group chats?
Yes. OpenClaw agents can respond in Telegram group chats. Add your bot to a group and it will respond when mentioned with @yourbotname or when configured to listen to all messages. For group use, set your agent's SOUL.md to handle multi-user context and keep responses concise so the chat stays readable.
How much does it cost to run an AI agent on Telegram 24/7?
The Telegram side is free. Your costs come from the AI model provider and hosting. A lightly used agent (50-100 messages per day) costs roughly $1-5/month with Anthropic Claude. Hosting is free if you run on your Mac. A Raspberry Pi costs about $3-5/month in electricity. A VPS starts at $4-6/month. Total: under $10/month for an always-on Telegram AI agent.
Can I run multiple AI agents on the same Telegram account?
You need one Telegram bot per agent, but you can run multiple bots from a single OpenClaw installation. Each bot gets its own token from BotFather and its own SOUL.md configuration. A single machine (Mac, Pi, or VPS) can comfortably run 3-5 agents simultaneously when using cloud APIs for inference.
What happens to messages when my agent is offline?
Telegram queues messages for your bot when it is offline. When your agent comes back online, it receives all pending messages and processes them in order. With the auto-start configurations shown in this guide (launchd, systemd, or Docker), your agent restarts automatically after reboots or crashes, so downtime is typically seconds, not hours.
Build Your Telegram Agent in Minutes
Pick a role, customize the SOUL.md, and deploy your AI agent on Telegram. The generator has 20+ templates ready to go.