XavierFok
← all posts

The Telegram bot that runs my automations

2026-08-15 · by Xavier Fok

# The Telegram bot that runs my automations

My entire automation setup answers to a chat app on my phone. No dashboard, no web panel, no remote desktop session. I send a message the way I would text a friend, and a few seconds later the answer comes back: the render finished, the backup ran clean, the job failed on step three. When I first wired this up I expected it to feel like a hack held together with tape. Instead it felt like the most natural addition I had made in years, which surprised me enough that I want to lay out how it works, why a chat interface turned out to be such a good fit, and the safety decisions that make it something I can actually trust.

Why chat fits this job

The fit was the part I did not see coming, so let me explain it before the mechanics.

Reach comes first. Telegram runs on my phone, my tablet, and my laptop, from anywhere with a signal. The bot process sits on my server and connects outward to Telegram, so nothing on my end faces the public internet. No open ports, no VPN to stand up, no thinking about my IP address. A command sent from an airport lounge lands the same as one sent from my desk, and the answer arrives in my pocket.

The interface itself is bare text, and for a tool used by exactly one person, that is the correct amount of interface. There are no buttons to wire up and no forms to design. I type what I want. The bot replies with what happened.

The last piece is push. When something finishes or breaks while I am not watching, the bot messages me the moment it happens. I never go open a panel to find out. That inversion, information arriving instead of being fetched, changes your relationship with your own systems more than any single feature, and once you have lived with it, a passive dashboard feels like a step backward.

The loop from message to reply

The architecture is smaller than most people assume. When I send the bot a message, five things happen in sequence.

The message reaches the bot through Telegram's own delivery, either because my code is polling for new messages or because Telegram pushes them, depending on configuration. Next, the bot checks who sent it, and I will come back to this properly, because it is the load bearing wall of the whole design. Then the bot looks up what I typed in a small table of commands, each one a word or short phrase mapped to a function. A recognized command runs its function; anything else gets a polite reply saying the command is unknown, and nothing more. The function does the actual work, reading a log, launching a script, checking whether a process is alive. Finally, whatever the function returned comes back to me as a reply.

The full round trip usually takes a few seconds. Picture four boxes in a line: me on my phone, the bot checking identity and intent, a small script running on my machine, the reply landing back in the chat. Nothing in that picture is complicated on its own. The glue between a chat app, a command table, and scripts you probably already have is genuinely thin.

What I actually use it for

Theory aside, here is the traffic this bot really carries.

Status checks make up most of it. Is the background job still running, what was the last log line, did a file show up in the folder yet. It sounds trivial until you are out somewhere wondering whether a long render finished, and instead of waiting until you get home, you just ask.

Second, on demand jobs. Some tasks I keep off any schedule because they should only run when conditions are right, and those conditions are hard to detect automatically. For those, I send a short command, the bot starts the job, and it messages me when the work is done.

Third, reports. I have scripts that summarize recent activity, items processed, errors hit, what the counts look like. I used to run them at a desk. Now I read the answer wherever I happen to be.

The fourth use quietly changed how I feel about my whole setup: failure alerts. Jobs check in with the bot at the end of every run, and anything that went wrong becomes a message to me. I stopped going to look for problems, because the problems now come to me, within seconds, in the same channel I already read all day. For anyone running a setup of real size, that single behavior is worth more than every other feature combined, and it costs almost nothing to build.

The safety layer

A bot that can run scripts on your machine deserves real paranoia, so this is the section I take most seriously.

Rule one, with no exceptions: only I can talk to it. Every incoming message gets its Telegram user ID checked against my own ID, hardcoded in the configuration. Anything else is ignored and logged as unexpected. There is no admin list, no guest mode, no whitelisted group. One ID.

Rule two: every command is explicit. The bot never interprets natural language or guesses intent. It has a fixed list of recognized commands, and everything outside the list gets the unknown command reply. The attack surface is therefore exactly the set of things I chose to expose, and nothing else.

Rule three: destructive actions require confirmation. Any command that deletes, overwrites, or shuts something down triggers a question instead of an action, and I have to send a second message to confirm. The confirmation expires after thirty seconds of silence, after which nothing happens. It feels like friction and it is the right kind. Twice now it has caught me after I typed the wrong command, when the bot asked me to confirm something I definitely did not want.

What stays off the bot

The commands I refused to add matter as much as the ones I built.

Anything touching live production data goes through a proper process with version control and review, never a chat shortcut. Secrets and credentials do not live anywhere near the bot. A script that I have not already run by hand many, many times does not get a command, because the bot is only allowed to surface things I trust completely. It is a narrow window onto proven work, never a place to experiment.

Whole categories are excluded outright. Nothing with financial side effects, no billing, no payment triggers. No database writes, though reads are fine. No third party service that lacks its own audit log. And no command for anything that requires judgment. If a decision needs me to actually think, it has no business having a one word shortcut. The bot exists for actions whose outcome is always the same and where the only variable is when I want them to happen. The judgment stays with me.

Earning my own trust

I did not wire this up and start firing commands on day one. Every function the bot calls ran first as a standalone script, over and over, until its output was completely predictable. Only then did the bot layer go on top, and each command got tested where a mistake could not hurt anything before it touched real work.

Everything is logged. Every message received, every action taken, every reply sent, all of it lands in a log file. When something behaves in a way I do not understand, I can reconstruct exactly what happened. That log has no optional status in my mind. It is how you catch the edge case you failed to imagine while building.

The honest limits

Build videos love to skip this part, so I will not.

The bot is only as available as the machine under it. When my server goes down, the bot goes with it, and early on I sent commands into silence a few times because the machine had rebooted and the bot process had not come back cleanly. A proper restart policy fixed it, and the lesson stuck: never assume the thing you built around is simply always there.

Long jobs need asynchronous handling. Anything running beyond a minute has to reply later with a completion message rather than making the chat wait, or it would just time out. I built that in early, and it is essential.

And the text interface, the very thing that makes this great, is also its ceiling. Charts, image comparisons, anything visual, none of it travels usefully through a chat message. Those needs go through a different interface. The bot handles what text handles well, and I stopped asking it for more.

If you build your own

Start with one command. Resist the menu. One command for the thing you check most often, made to work perfectly, will teach you the architecture, the error handling, and the failure modes before twenty things depend on the result. Put the user ID check in before anything else, literally the first lines that touch a message. Treat confirmation as mandatory for anything that writes or deletes. Log everything from the first test run, since the log is your only record of what actually happened.

Once the first command works cleanly, the second takes minutes. The hard parts are the first command and the safety layer, and after those it is just more rows in a table.

This is one of the builds I am most glad I did. Described out loud it sounds modest, a chat bot that runs scripts, but it changed how connected I feel to everything I operate. I can check anything, start anything, and hear about any failure, from anywhere, with no extra infrastructure. An afternoon to build, months of trust since, and the only change has been adding commands.

Check out more breakdowns like this at [xavierfok.com](/).

Get new guides and videos first — join the Telegram channel.