Skip to content
Development PY—02

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.

10 modules25 lessons
20 hoursof video and practice
Python basics neededrequirements
Foreveraccess and updates
Format
€72 one-off payment
Place the order Open the programme
Payment by card or through PayPal
Access opens immediately after payment
14-day refund, if you have not started watching
Outcome

What you will be able to do

Get a bot running on the Bot API and handle commands
Build dialogues with states, keyboards and inline buttons
Store users and orders in the bot's database
Take payments and run a subscription inside the bot
Connect the bot to external services by API and on a schedule
Deploy the bot to a server and keep an eye on failures
Programme

10 modules, one project

Press a module to open its lessons

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.

How the Bot API works: updates, methods, limits
Registering a bot, the token and environment variables
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.

A minimal bot: launching it, /start and the first reply
Handlers and filters: commands, text, any update
Formatting replies and handling 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.

Reply keyboards: menus, contacts, hiding after a choice
Inline buttons, callback_data and editing a message
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.

The state machine: questionnaire steps and the moves between them
Storing a step's data and validating the user's answers
Cancelling, going back and leaving a scenario
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.

The table schema: users, dialogues, orders
SQLite and SQLAlchemy: queries from handlers
Migrations and backups without stopping the bot
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.

Receiving photos, documents and voice messages: file_id and downloading
Sending media, albums and generating a file on the fly
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.

Long polling: how it works and where it hits its limits
The webhook: HTTPS, the secret token and debugging 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.

Invoice, payment and confirmation: the whole payment path
Subscription: period, renewal, reminders and access
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.

Calls to external APIs: keys, errors, rate limits
Scheduled tasks: reminders and regular reports
Mass notifications and broadcasts without blocking the bot
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.

Server, systemd and Docker: running the bot as a service
Logs, monitoring and restarting after a failure
Final project: deploying your own bot and checking it
Materials

What you get

25 lessons with transcripts

Videos with timecodes and a written version: you can return to the piece of code you need without rewatching the whole lesson.

Code templates for every module

A starter project and a finished solution: compare your bot with the reference and find the step where the behaviour diverged.

A bot template with a database and deployment

The project skeleton: file structure, config, database connection and the files for running it on a server — the base for your final bot.

A pre-deployment checklist

Checks on tokens, error handling, rate limits, logs and restarts — point by point, so the bot does not go down on its first day.

Course author

Svetlana Burnusus

Teaches the «Bots and automation» direction at Forma. The full list of their courses is on their page.

All courses by this author

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.