A lightweight Telegram-based barber booking system built with Dart and the Telegram Bot API, designed to simplify appointment booking directly inside Telegram.
The bot allows customers to browse available services, select a date and time, choose an available barber, confirm their appointment, and view their existing bookings โ all through Telegram's inline keyboard interface.
- ๐ Book barber appointments directly through Telegram
- ๐ Select available barber services
- ๐ Choose an appointment date
- ๐ Select an available time slot
- ๐ค Automatically find available barbers
- ๐งพ Review booking details before confirmation
- โ Confirm appointments
โ ๏ธ Prevent double booking for the same barber and time
- โ๏ธ Haircut
- ๐ง Beard trim
- ๐ Haircut + Beard
- โฑ๏ธ Service duration management
- ๐ค Barber service availability
- ๐ง Temporary session management
- ๐ Track the user's current booking process
- ๐ Store selected service, date, time, and barber
- โ Cancel an active booking process
- ๐ View personal bookings
- ๐ค Display assigned barber
- ๐ Display selected service
- ๐ Display appointment date
- ๐ Display appointment time
- ๐ค Telegram Bot API integration
- ๐ฌ Telegram message handling
- ๐ Inline keyboard navigation
- ๐ Callback query handling
- โ๏ธ Dynamic message editing
- ๐ก Long polling update handling
โ ๏ธ Telegram API error handling
- ๐ฑ Fully Telegram-based interface
- ๐ Interactive inline keyboards
- ๐ข Available time slots
- ๐ด Unavailable time slots
- โ Booking confirmation screens
- โน๏ธ Built-in help section
- โ Booking cancellation
| Technology | Usage |
|---|---|
| ๐ฏ Dart | Programming language |
| ๐ค Telegram Bot API | Bot communication and messaging |
| ๐ HTTP | HTTP requests to Telegram API |
| ๐ Long Polling | Receiving Telegram updates |
| ๐ง In-Memory Storage | Temporary bookings and sessions |
| ๐ฆ JSON | API request and response handling |
The project follows a lightweight service-oriented structure suitable for a Telegram bot MVP.
telegram_barber_bot/
โ
โโโ bin/
โ โโโ telegram_barber_bot.dart
โ
โโโ screenshots/
โ โโโ main-menu.png
โ โโโ services.png
โ โโโ booking.png
โ
โโโ pubspec.yaml
โโโ pubspec.lock
โโโ README.md
Handles communication with Telegram using the Bot API.
The bot communicates with Telegram through methods such as:
getUpdates
sendMessage
editMessageText
answerCallbackQuery
The booking flow is handled through a sequence of user selections:
๐ Main Menu
โ
๐
Book Appointment
โ
๐ Select Service
โ
๐ Select Date
โ
๐ Select Time
โ
๐ค Select Barber
โ
๐งพ Booking Summary
โ
โ
Confirm Booking
Each barber has a list of services they can provide.
Example:
const StaffItem(
'ali',
'Ali',
{'haircut', 'beard', 'combo'},
);The system checks staff availability based on:
- ๐ Selected service
- ๐ Selected date
- ๐ Selected time
- ๐ Existing bookings
Each Telegram user has a temporary session:
class UserSession {
String? vendorId;
String? serviceId;
String? date;
String? time;
String? staffId;
}This allows the bot to maintain the user's progress throughout the booking process.
The project currently uses three main data structures.
Represents a barber service.
ID
Name
Duration
Represents a barber and the services they provide.
ID
Name
Service IDs
Represents a customer appointment.
User ID
Username
Vendor ID
Service ID
Staff ID
Date
Time
git clone https://github.com/CodeminTech/telegram_barber_bot.gitcd telegram_barber_botdart pub getOpen BotFather in Telegram and create a new bot.
Copy the generated Bot Token.
dart run -DBOT_TOKEN="YOUR_BOT_TOKEN"Example:
dart run -DBOT_TOKEN="123456789:YOUR_BOT_TOKEN"The Telegram Bot Token is provided through Dart's compile-time environment variables:
const botToken = String.fromEnvironment('BOT_TOKEN');The application checks whether the token is available before starting:
BOT_TOKEN is missing.
This approach keeps the token outside the source code.
The current version uses in-memory storage for bookings and user sessions.
final bookings = <Booking>[];
final sessions = <int, UserSession>{};This makes the current version suitable for:
- ๐งช MVP development
- ๐ฏ Prototyping
- ๐งโ๐ป Development
- ๐ Demonstration
However, all booking data will be lost when the application stops or restarts.
The bot dynamically checks barber availability before displaying time slots.
Selected Service
โ
Selected Date
โ
Selected Time
โ
Available Barbers
โ
๐ข Available
or
๐ด Unavailable
A time slot becomes unavailable when all eligible barbers are already booked for that specific date and time.
| Command | Description |
|---|---|
/start |
๐ Start the bot |
/menu |
๐ Open the main menu |
/bookings |
๐ View personal bookings |
/cancel |
โ Cancel the current booking process |
This project was developed to demonstrate practical experience with:
- ๐ฏ Dart development
- ๐ค Telegram Bot API integration
- ๐ REST API communication
- ๐ Long polling
- ๐ Telegram inline keyboards
- ๐ง Session management
- ๐ Appointment booking logic
โ ๏ธ Availability and conflict handling- ๐งฉ Building a real-world Telegram automation MVP
The current MVP can be extended with additional features such as:
- ๐๏ธ Persistent database storage
- โ๏ธ Supabase integration
- ๐จโ๐ผ Admin management panel
- ๐ค Customer management
- ๐จโ๐ง Barber management
- ๐ Full calendar system
- ๐ Appointment reminders
- โ Appointment cancellation
- ๐ Appointment rescheduling
- ๐ณ Online payment
- ๐ Booking statistics
- ๐ช Multi-barber-shop support
- ๐ Web-based management dashboard
- โ๏ธ Cloud deployment
The current in-memory implementation can later be evolved into a production-ready system:
โโโโโโโโโโโโโโโโโโโโ
โ Telegram โ
โ Client โ
โโโโโโโโโโฌโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโ
โ Dart Bot API โ
โ Backend โ
โโโโโโโโโโฌโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโ
โผ โผ โผ
๐ค Customers ๐
Bookings ๐ Staff
โ โ โ
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโ
โผ
โโโโโโโโโโโโโโโโโโโโ
โ Database โ
โโโโโโโโโโโโโโโโโโโโ
CodemonTech
Flutter Developer | Mobile Application Developer
๐ GitHub: GitHub: https://github.com/CodeminTech


