Telegram AI bot with Claude — a 5-minute self-hosted setup
Build a Telegram bot powered by Claude (or any LLM) without a SaaS in the middle. Step-by-step setup with openclawOS, @BotFather, and Pi.
- telegram
- claude
- tutorial
- bot
Telegram is the cleanest bot platform on the consumer internet. You don’t need to verify a business, pay for a Cloud API, or expose a webhook URL. Five minutes from “I want a Telegram AI bot” to “it works”.
This is how to do it with openclawOS — self-hosted, your model of choice, full Pi agent capabilities.
Step 1: Install openclawOS
npm install -g openclawos@latest
openclawos onboard --install-daemon
The Control UI opens on localhost:7777.
Step 2: Create a bot
Message @BotFather on Telegram. Send /newbot. Pick a display name and a username ending in bot. BotFather hands you a token that looks like 123456789:ABCdefGhIJKlmnopqRstuv.
Copy it.
Step 3: Pair Telegram
openclaw apps install telegram
The CLI prompts for the token. Paste, hit enter. Or do it from the Control UI’s Channels tab.
Step 4: Drop in your LLM key
In the Control UI’s Providers tab, paste your Anthropic API key. We recommend Claude Opus 4.6 for Pi’s full tool-use behaviour; Sonnet 4.6 also works and is cheaper.
If you’d rather use OpenAI, Gemini, or a local Ollama, those work too — pick in the dropdown.
Step 5: Say hi
Open your bot in Telegram. Send /start. Pi responds. Try:
- “What’s on the front page of Hacker News?”
- “Summarise this PDF” (attach a file)
- “Remember that I’m vegetarian and based in Berlin”
You’re done. Total time: under 5 minutes assuming you didn’t refill your coffee.
What you can do from here
Commands Pi auto-registers
/new— start a fresh session (forget current memory)/fork— branch the current session/summary— compact the current session/agents— list available agents (if more than one)/help— Pi explains what it can do
These all show up in BotFather’s command list if you choose to publish them.
Bind to a group
By default Pi only listens to DMs. To make it active in a group:
# ~/.openclaw/bindings/telegram-team.yaml
trigger:
channel: telegram
scope: { groupId: "-1001234..." }
match:
mentions: ["@your_bot"]
agent: pi
session:
scope: group
Now @your_bot what did we discuss yesterday? triggers Pi in that group.
Inline mode
In your bot’s settings on @BotFather, enable inline mode. Now in any chat, type @your_bot something — Pi will offer inline results you can tap to send.
Inline is great for summaries, code snippets, structured replies you want to drop into another conversation.
Multiple bots
Pair as many bots as you like. Each one is its own binding. Common setups:
@dipankar_dev_bot→ coding Pi, listens in your engineering Discord too@dipankar_personal_bot→ personal Pi, also handles your iMessage@dipankar_research_bot→ a research Pi with a different system prompt and different tools enabled
Cost expectations
A Telegram-Pi chatting with you a few dozen times a day costs $3-10/month in Claude Sonnet tokens. Opus is 5-10× more. Local models are free per token but the round-trip is slower and tool-use reliability is lower.
Privacy and rate limits
Telegram bot DMs are server-side; Telegram does see them as a vendor (they always have for any bot). The openclawOS Gateway sits between Telegram and your LLM — Pi processes only the latest turns, not your full history.
Rate limits: Telegram caps bots at 30 messages/second per chat, 20 messages/minute per group. Pi’s tool use never approaches this in normal use.
Beyond the basic loop
The fun starts when you wire bindings together. A common second move is connecting Pi to a vector store of your own notes, so you can ask Telegram-Pi about your Obsidian vault. Or wire a cron trigger to send you a morning brief on Telegram every day at 7am. Or expose Pi as a webhook so your CI can ping it when a build fails.
The Gateway handles all of this. Telegram is just the surface.
Frequently asked
Yes. Get one in 30 seconds from @BotFather — Telegram's own bot for creating bots. Send /newbot, pick a name, copy the token.
Related reading
How to build a self-hosted WhatsApp AI bot in 2026
A practical walkthrough of pairing WhatsApp to a self-hosted AI agent powered by Claude or GPT — using openclawOS, no Meta Business API, no cloud SaaS in the middle.
PR code review from Telegram, by way of Pi
How I review pull requests from the sofa: a Telegram binding that pipes GitHub PRs to Pi, who summarises diffs and surfaces likely regressions.
The complete guide to self-hosted AI gateways in 2026
What a self-hosted AI gateway is, why it matters, how openclawOS implements one, and a practical setup walkthrough — from zero to multi-channel agent in an afternoon.