A study breakdown of step-by-step dialogues in Telegram bots: how a bot remembers what it asked and where the answers go.
A breakdown of one topic: how to build a conversation of several steps inside a Telegram bot.
The task looks simple until it turns out the bot does not remember what it asked a minute ago — every message arrives on its own, with no thread attached. The answer is a finite state machine: each user has a current state, a handler fires only in the state it belongs to, and the answers collected so far accumulate until the form is complete.
The repository holds the routers, the keyboards and a project skeleton that is comfortable to start your own bot from.
The booking form in the restaurant bot grew directly out of this — the same technique applied to a real problem, where getting the state wrong means a guest loses their table.
A fragment of the project's real code — so you can see what's inside.
from aiogram import Bot, Dispatcherfrom app.handlers.start import router as start_routerfrom app.handlers.custom import router as custom_routerload_dotenv()TOKEN = getenv("BOT_TOKEN") or ""setup_logger()logger = logging.getLogger(__name__)dp = Dispatcher()dp.include_routers(start_router, custom_router)async def main(): bot = Bot(token=TOKEN) await dp.start_polling(bot)if __name__ == "__main__": asyncio.run(main())Project request
Fill in the form — we'll discuss scope and timing.
IT² Hub — studio website
