How Claude sits in my Telegram
Translated from Russian. Original
People ask often, so here it is. It's simpler than it looks.
Why not a bot
A bot sees only what was written to it in the chat. It won't read my chat with a partner from last year, won't find a file sent in March, won't post a story and won't write as me.
So I don't use a bot, I use MTProto - the same protocol Telegram itself runs on. Claude logs in as one more of my devices. Like Telegram on a MacBook, only an agent instead of a person. It sees exactly what I see and can do exactly what I can do.
How it's built
Python + Telethon. You get api_id and api_hash at my.telegram.org, log in once by QR (on the phone: Settings → Devices → Link Desktop Device). You get a session file, and it lives forever after that.
On top, a CLI of a hundred lines: find a chat, read, send, download attachments. Claude knows about it from a skill - a plain markdown file: "asked to write in Telegram → run this command". No MCP, no server. The model just types a shell command, the same way I would type it myself.
Separately, a sync runs every 15 minutes: it pulls the history of all chats to disk, incrementally. I have 1.2 GB of text, the agent reads it as normal files.
How I use it
- "Set up a bot for the new project" - it goes to @BotFather, goes through the whole dialog, takes the token and puts it in the config. On its own, I don't even look
- "Post a story with a link to the post" - a bot can't post stories at all, only a live account can. But an agent with my session can
- "What did Ilya and I decide on the design?" - it doesn't ask me again, it goes and reads the chat and answers from the facts
- "Figure out what Oleg asked for, do it, and when it's done write to him" - it looks at what they want from me, does it, sends the reply
Pitfalls
One key = one device. Copy the session file to a second computer - Telegram sees two IPs with one key and burns the session. Been there, logged in again.
And the agent doesn't listen to incoming messages: it doesn't reply on its own until I ask. This is on purpose - I don't want it talking to people for me without asking.