К содержимому
Hub
Restaurant table booking bot

Restaurant table booking bot

Bots2026Pythonaiogram 3SQLiteTelegramFSM

A Telegram bot for a restaurant: the guest picks a date, time and table, the admin approves it in chat. Double booking is impossible at the database level.

A bot through which a guest books a table while the administrator confirms or declines the request directly in the chat.

For the guest: a step-by-step form — date, time, number of people, table, contact details. Slots that are taken or already in the past are marked and cannot be selected, and only tables that fit the stated party size are offered. Guests can see their own bookings as a list and cancel in one tap. A phone number can be sent with a button or typed in, and it is validated either way.

For the administrator: a notification for every new booking with Confirm and Decline buttons, and the guest is told the outcome immediately. Reports cover today, tomorrow, any given day, and everything on file.

The central decision is how double booking is prevented. Checking availability with a query before inserting is unreliable: between the check and the write a second guest slips in, and both are recorded. The bug never shows up on a quiet day and is guaranteed on a Friday evening. So the rule lives in the database itself — a partial unique index on table, date and time, with cancelled bookings excluded. Two simultaneous requests for the same slot physically cannot both be stored.

Python 3.11, aiogram 3, SQLite. Async throughout, a finite state machine for the multi-step form, and dependencies injected into handlers through aiogram's own mechanism.

How it's built

A fragment of the project's real code — so you can see what's inside.

Repository
SQL
CREATE TABLE IF NOT EXISTS bookings (    id         INTEGER PRIMARY KEY AUTOINCREMENT,    user_id    INTEGER NOT NULL,    username   TEXT,    table_id   INTEGER NOT NULL REFERENCES tables(id),    book_date  TEXT    NOT NULL,    book_time  TEXT    NOT NULL,    guests     INTEGER NOT NULL,    status     TEXT    NOT NULL DEFAULT 'pending');-- Один столик нельзя занять дважды на один и тот же слот.-- Отменённые брони из проверки исключаются.---- Проверять занятость запросом перед вставкой ненадёжно: между-- проверкой и записью успевает вклиниться второй гость. Здесь-- запрет живёт в самой базе, и обойти его нельзя.CREATE UNIQUE INDEX IF NOT EXISTS idx_booking_slot    ON bookings (table_id, book_date, book_time)    WHERE status <> 'cancelled';CREATE INDEX IF NOT EXISTS idx_booking_user ON bookings (user_id);CREATE INDEX IF NOT EXISTS idx_booking_date ON bookings (book_date);
Get in touch

Project request

Fill in the form — we'll discuss scope and timing.

Regarding: Restaurant table booking bot
Next project

TechnoMarket — electronics store