Telegram bots and automation
A Telegram bot is the shortest route from an idea to a working product, and we take the Bot API apart piece by piece: messages, buttons, dialogue states, the database, payments and integrations. By the end you have a working bot on a server, not a draft in an editor.
What you will be able to do
10 modules, one project
01 The Bot API, the token and the environment2 lessons · 1 h 20 minOpen
How Telegram passes messages to a bot and what the Bot API can do. We register a bot, get a token, store it safely and set up a Python environment — the base from «Python from scratch» is needed here.
02 The first bot: commands and messages3 lessons · 2 h 28 min
We build a minimal bot and run it locally. We cover the update loop, handlers for commands and text messages, formatting replies and handling errors so the bot does not fall over on unexpected input.
03 Keyboards and inline buttons2 lessons · 1 h 37 min
Two kinds of keyboard and when each is needed. We build a menu on a reply keyboard, inline buttons with callback data, handle presses and edit an already-sent message instead of sending a new one.
04 Dialogue states and scenarios3 lessons · 2 h 26 min
How to lead a user through a multi-step scenario: a questionnaire, placing an order, cancelling at any step. We cover the state machine, storing data between steps and switching between scenarios without losing context.
05 The bot's database3 lessons · 2 h 26 min
We connect SQLite and move users, settings and orders into it. We design the tables around the bot's tasks, write queries from the handlers and make sure a restart does not lose data.
06 Files and media2 lessons · 1 h 33 min
The bot accepts photos, documents and voice messages and sends them back. We cover file_id, uploading and downloading, size limits, albums and generating a file on the fly — a report, for instance.
07 Webhooks versus long polling2 lessons · 1 h 40 min
Two ways to receive updates and the price of each. We compare long polling and webhooks, set up a webhook with HTTPS, and cover repeated deliveries, the update queue and debugging locally through a tunnel.
08 Payments and subscriptions in a bot2 lessons · 1 h 44 min
How to take money inside a bot. We go through the invoice, the payment, the confirmation and the refund, then build a subscription: the access period, renewal, reminders and cutting features off once the paid period ends.
09 Integrations and automating the routine3 lessons · 2 h 19 min
The bot as the link between services. We call external APIs, handle errors and rate limits, schedule tasks and send notifications to a group of people without launching anything by hand.
10 Deployment and the bot's life on a server3 lessons · 2 h 27 min
We deploy the bot to a server and make it work unattended: systemd or Docker, environment variables, logs, restarting after a crash and updating the version. The final project is a working bot on a server.
What you get
Videos with timecodes and a written version: you can return to the piece of code you need without rewatching the whole lesson.
A starter project and a finished solution: compare your bot with the reference and find the step where the behaviour diverged.
The project skeleton: file structure, config, database connection and the files for running it on a server — the base for your final bot.
Checks on tokens, error handling, rate limits, logs and restarts — point by point, so the bot does not go down on its first day.
The whole first module is open
Watch the lessons of the first module and the first task. If the format does not suit you, you have lost nothing.