← All projects
Government-system emails become a completed permit

How I Built a Telegram Bot with AI for Business

October 31, 2026 · Vasilii Anisimov

I'm an economist, not a programmer. My company, Specraz (спецраз.рф), arranges special permits for oversize and overweight cargo. My first AI-built bot was a mail bot: it receives emails from a government system and sorts them into chats. Everything else I'm building now started there. Here is how it happened, without sugarcoating.

Why I Needed a Bot

Special permits for oversize cargo are issued through the Safe-Route government system. It communicates by email: application statuses, completed permits, and two-factor sign-in codes.

That is manageable with a few customers. Once you have hundreds of customers and about a dozen orders a day, you end up with a dozen different carrier inboxes.

This is what signing in to a carrier account looked like. Open a Safe-Route tab, then a tab for that carrier's email. Sign in to the email, then enter the username and password in Safe-Route. The two-factor code arrives by email, so you go back, copy it, and paste it. Meanwhile, three, four, sometimes five applications are in progress. That means five account tabs and five email tabs.

There was also waiting. The government system can be slow: a state-duty invoice may not appear, or an application may take a long time to register. I had to keep checking the account or email. You can turn on email notifications, but they pop up for every message and become annoying. We also paid state duties manually by entering the UIN into a payment-order template.

I did not need another email client. I needed the right email to arrive automatically where the team was already working: Telegram.

Government-system email: before and after
Government-system email: before and after

What I Built

The bot is called @saferouteru_bot. It is public and has been running since July 2025.

There is more: team invitations and member permissions, inbox-quota monitoring and cleanup of old emails, moving vehicles between accounts, exporting permits to CSV for partners, a public navigator, and MAX (a Russian messenger) integration. The bot works as a delivery channel for permits, state-duty invoices, and statuses across the logistics operation.

How a Safe-Route email reaches a chat
How a Safe-Route email reaches a chat

Since September 2026, the emails have had an archive: the “Safe-Route Emails” tab in SUZ (our order management system). It collected 660 emails in its first two days.

Bot: route-building results with route links
Bot: route-building results with route links

How I Built It

This was my first project that worked. When I started, I copied code from ChatGPT into the terminal. Then I discovered VS Code with Claude Code built in, and everything changed.

The bot has never been rewritten from scratch. It grows in layers, like a progressive JPEG: first a rough but working image, then the details.

How I Work with AI Agents

I do not write code. My job is to explain what hurts and check whether it got better. Claude Code handles the plan and task breakdown, Codex writes the code, and another AI agent reviews every change. Deployment is one button with a log.

Tasks are split by risk. AI handles the small things on its own. Anything involving money, writing to a government system, or irreversible actions waits for my “go ahead.” The mail bot has many such moments: it sends documents to customers, and you cannot take an email back.

What Went Wrong

Versions in names and manual rollbacks. In the first weeks, a “version” was a number in the commit message. The history has an entry from July 10, 2025: “restore stable version 118ad82.” Something broke, and I rolled it back manually. Lesson: if you cannot quickly return to a working version, every improvement is a gamble. Now rollback is a normal part of deployment.

Lost codes. The bot can sign in to a Safe-Route account on its own, which makes the government system send a code. To avoid showing people unnecessary codes, I enabled suppression: if an automatic sign-in was running then, the code was hidden. At one point, frequent automatic sign-ins caused the suppression to hide human-requested codes too: 337 of them in two days. Now the bot still delivers the code, just marked “possibly requested automatically.” The codes are one-time, so no major harm was done. Lesson: when in doubt, an extra notification is better than a lost code.

Another agent and the secrets file. Once, my five-hour Claude limit ran out on the $20 plan, and I decided to experiment by giving Gemini a task. It wiped every key and password from the settings file. It hurt: I had to restore everything. Lesson: back up your secrets file, and try a new tool on a copy of the project first.

A permit with the wrong dimensions. Sometimes the dimensions in a permit are smaller than in the customer's brief. This happened to us. The customer got lucky and noticed in time. Otherwise, they could have faced a fine of 600,000 rubles. At first, I only added a warning in the chat. Then I added a hold: the permit waits for the “Everything is correct — send to customer” button. I enabled it gradually: off, then “shadow” mode (the bot only logged that it would have held it), then live mode. Lesson: anything you cannot retract, such as an email to a customer, goes behind a flag and starts in shadow mode.

A crash in the middle of sending. If the bot crashes while sending a permit to a customer, you do not know whether it was delivered. Send it again, and the customer may receive a duplicate. Do not send it, and the customer waits. I chose this: if the outcome is unknown, the bot sends nothing and tells the team, “send it manually.” Lesson: one extra manual step is better than a document sent twice.

What got better. Instead of ten tabs, there is one chat. Sign-in codes, state-duty invoices, and statuses arrive automatically, and only for the events that matter: you can immediately see that an invoice arrived or an application was registered. There is no need to cycle through accounts anymore.

Numbers

I described the cost of working with AI agents and servers in my article about the order management system.

Could This Work for You?

The job is done: emails sorted, permit with customer
The job is done: emails sorted, permit with customer

If you have already tried vibe coding yourself and got stuck—on architecture, deployment, or AI breaking something that worked—message me. I can explain how something like this could be built for you.

Message me on Telegram