What an appointment booking bot has to do
A minimal booking bot does one job: the client picks a service, a date and a time, and the owner gets a confirmed booking with no calls or back-and-forth. Everything around it decides whether it is pleasant to use or falls over under real load.
Before writing code, pin down the scenarios: who books (new or returning clients), whether there are several specialists or rooms, whether a prepayment is needed, whether a client can book several services in a row. These answers shape the data model, and changing it after launch is the most expensive kind of rework.
- Choosing a service and, if needed, a specialist.
- Showing only slots that are really free.
- Booking confirmation and a notification to the owner or admin.
- A reminder to the client before the visit.
- Cancel and reschedule by the client within the rules.
- A list of bookings for the owner: by day, by week, by specialist.
How to calculate free slots
A slot is not a row in a "times" table. It is the result of a calculation: a specialist's working hours, minus existing bookings, minus breaks, taking the duration of the chosen service and any buffer between clients into account. Pre-generating every slot a year ahead is awkward, because any schedule change forces a recalculation.
It is more practical to store rules (working hours by weekday, exceptions, time off) and bookings as start-end intervals, and compute free windows on request. A 90-minute service must not fit into a 60-minute gap, so duration takes part in the calculation, not just the start time.
- Schedule rules: working hours, breaks, days off, time off and one-off exceptions.
- Service duration and a buffer before the next client.
- Bookings stored as start-end intervals, not only a start time.
- A configurable slot grid step, for example every 15 or 30 minutes.
- A minimum lead time, so nobody books "in five minutes".
Time zones when clients are in different cities
Telegram does not tell a bot the user's time zone: it is not part of the data a bot receives. So a bot either assumes everyone lives on the business's local time, or asks explicitly. For on-site services the first option is usually right: bookings use the venue's local time and the bot always states which time a meeting is set in.
If services are online and clients are in different cities, ask for the zone at the first booking and save it. Store the booking time in UTC together with the business's zone name (for example `Europe/Berlin`), not an offset: offsets change with daylight saving where it exists. Show the client the time in their zone and put the zone into the confirmation text.
Protecting against double booking
Double booking happens when two clients choose the same slot at once: both see it free, both press the button. A "is it free?" check in code before the insert does not protect you, because time passes between the check and the write, and the second booking goes through.
Reliable protection lives in the database. PostgreSQL has an exclusion constraint on time ranges: the database itself rejects a second booking that overlaps the first for the same specialist. The bot gets an error and tells the client "that slot was just taken, pick another time". Then a race between two taps cannot put two clients at the same time.
- A database-level rule: overlapping intervals for one specialist are not allowed.
- Idempotency: a repeated button tap or a redelivered update must not create a second booking. See idempotency and retries.
- A short hold on a slot during confirmation or payment, released automatically by a timer.
- A clear message if the slot is taken, with the nearest free ones offered right away.
Cancelling and rescheduling
Cancellation rules are best settled before development because they affect both the interface and the data. Can a client cancel an hour before? Can they reschedule endlessly? What happens to a prepayment? The bot has to know the rules and give the client a clear answer instead of silently refusing.
Technically, rescheduling is cancelling the old booking and creating a new one in a single transaction: if the new slot is taken, the old booking stays. Keep history: a booking status (confirmed, cancelled by client, cancelled by admin, no-show) rather than deleting rows. That data helps with statistics and with disputes.
Reminders that actually arrive
A bot can only message a user after that user has started a conversation with it. So booking has to happen inside the bot, not by a phone number alone. If a client blocks the bot, the message will not arrive: handle that case instead of treating the reminder as sent.
It is better to store reminders as tasks with a due time in the database and process them with a background worker that picks up due tasks, sends the message and records the result. That way reminders survive a bot restart and don't get lost. Building such queues in Go is covered in background jobs and queues. When a booking is moved or cancelled, the reminder has to be cancelled or recreated.
- Reminders as database tasks with a due time and a status.
- Cancel or recreate the reminder when a booking changes.
- Handle the "user blocked the bot" error and mark it on the booking.
- Telegram limits how fast a bot can send: bulk sends need pauses between messages.
- A button in the reminder: confirm or cancel.
Calendar sync and other systems
If a specialist keeps their schedule in Google Calendar or another tool, you need to decide which one is the source of truth. One-way sync (the bot writes to the calendar) is simple and reliable. Two-way sync (calendar changes affect the bot's slots) is useful but requires conflict resolution and careful handling of recurring events.
If bookings also need to reach a CRM, pass them on from the same transaction or through a queue. How that works is in bot and CRM for leads. The general dialog mechanics are in conversation state in a Telegram bot.
What to decide before development
Booking looks simple but hides many decisions that are hard to change later: one specialist or several, whether a prepayment is needed, the cancellation rules, one time zone or many, where the schedule comes from. List them and decide before the first screen. That saves the most time.
If you want more than buttons, look at Telegram Mini Apps: date buttons work for short lists, while a dense schedule is clearer in a calendar inside a mini app. What drives the price of such a bot is covered in Telegram bot development cost.