Automation & Agents
Wire AI Into Telegram as a 24/7 Remote Assistant
What you'll be able to do: remote-control AI from your phone, 24/7, using an architecture where a cheap model handles the front desk (receiving messages) and the strong model you already subscribe to handles the back office (doing the work) — marginal cost near zero. No prior experience needed; every step is written to be copied directly, and stuck points come with an AI rescue prompt.
Before You Start: Two Terms in Plain Words
- Telegram: a free messaging app (like WhatsApp). We’ll create a “bot account” inside it — you message the bot, it asks AI to do the work, then sends the result back to you.
- Gateway: a small program running on your computer that acts as the switchboard — it receives Telegram messages, hands them to a cheap “front desk” AI to judge intent, and calls in a strong “back office” AI when the task is actual coding work. This guide uses the open-source tool Hermes Agent (by NousResearch, MIT licensed, free).
One Core Idea (the most important part of this whole guide)
Don’t let a single model do everything — split it into two roles:
- Front desk (cheap): receives messages on Telegram, judges what you want. A cheap model (like Gemini Flash) is plenty.
- Back office (strong, but already paid for): actually writes code and edits files. Run it directly through the AI dev tool you already subscribe to.
Benefit: the front desk is cheap, and the back office doesn’t need a separate expensive API — the marginal cost of the whole pipeline is close to zero.
Step by Step
Step 1 | Create a Telegram bot and get your “key”
- Open Telegram on your phone or computer, search for
@BotFather(Telegram’s official bot for creating bots), and open it. - Send it
/newbot. - It asks for a “bot name” — pick anything (e.g.
My AI Helper); then a “username” (must end inbot) — e.g.myai_helper_bot. - On success it gives you a long string like
8979xxxx:AAG...— this is your Token. Copy and store it, never share it. - Search for
@userinfobot, open it, send any message — it replies with a number, your user_id, which you’ll use for the whitelist later.
Stuck? Hand it to AI: paste the above and say “I’m using Telegram BotFather to create a bot, I’m at step X and seeing OO, what’s next?”
Step 2 | Install the Gateway (Hermes Agent)
- Search “Hermes Agent NousResearch GitHub” and go to its official GitHub page.
- Follow the README’s Installation section (Windows and Mac steps differ — follow the one for your system; prefer the official installer over any unofficial script).
- Once installed you’ll have a
config.yamlconfig file and a.envfile (where keys go).
This step trips people up the most — treat AI as your tech support. Copy this and ask (Claude or ChatGPT both work): “I’m installing the open-source tool Hermes Agent as a Telegram gateway on Windows (or Mac), I’m a beginner. Walk me through it step by step: from download, to install, to finding config.yaml and .env. Give me one step at a time and wait for my result before continuing.”
Step 3 | Pin the front desk to a cheap model
- Open
config.yamland set the model provider to the cheap model you want — never set it toauto(see pitfall #1 below). - Get an API key from that model’s provider and paste it into
.env.
Step 4 | Set up the “back office” as your AI dev tool
- Set the rule so that whenever the task is coding/engineering work, the front desk calls your dev tool’s headless (no-UI) command.
- Enable a permission mode restricting it to writing files only inside a designated working folder, and point it at that fixed folder.
Step 5 | Lock the whitelist and enable auto-start
- In
.env, set it to allow only youruser_id(from Step 1) — ignore everyone else’s messages. - Set the gateway to auto-start on boot (on Windows, the Startup folder works without admin rights).
- Set your computer’s power settings to never sleep, so it can genuinely run 24/7.
Step 6 | Run one test
From your phone, message your bot: “Create hello.py in the working folder that prints the current time.” Check whether it actually produces the file and replies. Works → success. No response → see pitfall #2 below.
The Three Pitfalls You Will Hit (this is the most valuable part)
Pitfall #1 — Never set the front-desk model to auto
provider: auto is unpredictable — it may silently pick an uncensored local model, or a free but rate-limited one, causing repeated error codes (404/429). Always pin the provider to the exact model you want.
Pitfall #2 — Inline comments in .env will silently break you (the #1 beginner trap)
Many .env parsers do not strip trailing # comments. This is wrong:
TELEGRAM_ALLOWED_USERS=123456 # my account <- WRONG!
The value becomes the literal string "123456 # my account", so the whitelist never matches and your messages get silently dropped — no reply, no error, very hard to diagnose. Never put a comment after a value in .env.
Pitfall #3 — Clean delegation comes from boundaries, not requests You’ll find that just telling the model in a prompt “hand coding off to the back office” isn’t enough — the front desk will still jump in and duplicate the work. What actually works isn’t clearer wording, it’s setting a real permission boundary: restrict the back office worker to writing files only inside a designated folder, so its output becomes the single source of truth and the front desk has nothing left to meddle with. Clean division of labor is designed, not requested.
Universal Rescue: How to Ask AI When You’re Stuck
Whenever you get stuck, fill in this template and hand it to AI (Claude or ChatGPT) — it’s ten times faster than googling it yourself:
I'm setting up "AI wired into Telegram as a 24/7 assistant" using Hermes Agent.
My OS is Windows (or Mac), and I'm a beginner.
I'm currently at Step X, I just did ____, and got ____ (paste exactly what you saw or the error message).
Please walk me through this in plain language, one step at a time, and wait for my result before continuing.
The key: paste the exact error message, say you’re a beginner, and ask for one step at a time. These three things turn AI into your personal coach.
One-Line Summary
The key to saving money is “cheap front desk + the strong back office you already pay for”; the key to stability is “clean division of labor forced by permission boundaries.” Get both right, and you have a 24/7, phone-controlled AI assistant at near-zero marginal cost.
This is part of an ongoing series of field notes and AI tool tests. To get the full SOPs and future posts, subscribe to the newsletter.
Support this work:Support on Ko-fi