Bots & Telegram

What is aiogram

What it is

A Python library for Telegram bots. It handles incoming messages, buttons and flows; the bot itself, its database and integrations are written on top of it.

How we use it

The base of all our Telegram bots: subscription sales, the ticket system, the finance assistant. The bot runs in a container on the client's server.

Why it matters to a business

A client never sees aiogram itself, but it shapes how the bot behaves:

  • the bot answers many people at once while someone's heavy request is still running;
  • an employee sees only the menu of their own role, and a blocked user never reaches the menu at all;
  • a request is filled in step by step, and the bot remembers which step a person stopped at;
  • the bot works without an open port or a public address.

How we use it

  • Roles through middleware. In the electronic queue the role is read from the database before every handler, so a student physically never sees the group leader's menu. The same bot limits rapid tapping to one request per 0.5 seconds. The help desk injects its four roles the same way.
  • Step-by-step dialogues (FSM). Adding a birthday, filing an IT ticket, creating a queue: a state machine remembers the step. In the help desk, unfinished dialogues live in Redis and survive a restart.
  • Polling or webhook. The subscription-sales bot polls Telegram by default, and webhook mode is switched on by a setting. The Peregovorka login bot uses long polling because it has no public address.
  • Heavy work goes aside. In the policy bot PDF processing runs in a separate thread; in the video downloader bot yt-dlp and FFmpeg run in separate processes, and the number of concurrent downloads is capped.
  • The version in sight. The bot writes its version to the log on startup, and a hidden /version command shows it to the administrator only, so you can see what is actually running on the server.

We build aiogram bots under Telegram and VK bots.

Common problems

  • In-memory states disappear. In the birthday bot and the electronic queue, an unfinished dialogue starts over after a restart. Where that matters, states move to Redis.
  • A single instance. When states and throttling live in process memory, the bot is designed to run as one instance.
  • Blocking code stalls everyone. A long operation in the main thread delays answers for every user, so it is moved to a thread or a process.
  • Permissions are checked on the server. A hidden command should answer a stranger as if it were a typo, not "you have no rights".

When you do not need it

If you want a bot you will edit yourself in a visual builder, aiogram is not it: it is code. For a simple broadcast or a new-lead alert, an n8n workflow without a separate bot is sometimes enough.

โ† All terms

Need a website, a bot or automation?

Terms explained โ€” now let's get to work: tell us about the task and we'll turn it into a clear work plan.