Skip to content

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ’ˆ Telegram Barber Bot

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.


โœจ Features

๐Ÿ“… Appointment Booking

  • ๐Ÿ“… 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

๐Ÿ’‡ Barber Services

  • โœ‚๏ธ Haircut
  • ๐Ÿง” Beard trim
  • ๐Ÿ’ˆ Haircut + Beard
  • โฑ๏ธ Service duration management
  • ๐Ÿ‘ค Barber service availability

๐Ÿ‘ฅ User Sessions

  • ๐Ÿง  Temporary session management
  • ๐Ÿ”„ Track the user's current booking process
  • ๐Ÿ“Œ Store selected service, date, time, and barber
  • โŒ Cancel an active booking process

๐Ÿ“‹ My Bookings

  • ๐Ÿ“‹ View personal bookings
  • ๐Ÿ‘ค Display assigned barber
  • ๐Ÿ’‡ Display selected service
  • ๐Ÿ“† Display appointment date
  • ๐Ÿ• Display appointment time

๐Ÿค– Telegram Bot

  • ๐Ÿค– Telegram Bot API integration
  • ๐Ÿ’ฌ Telegram message handling
  • ๐Ÿ”˜ Inline keyboard navigation
  • ๐Ÿ”„ Callback query handling
  • โœ๏ธ Dynamic message editing
  • ๐Ÿ“ก Long polling update handling
  • โš ๏ธ Telegram API error handling

๐ŸŽจ User Experience

  • ๐Ÿ“ฑ Fully Telegram-based interface
  • ๐Ÿ”˜ Interactive inline keyboards
  • ๐ŸŸข Available time slots
  • ๐Ÿ”ด Unavailable time slots
  • โœ… Booking confirmation screens
  • โ„น๏ธ Built-in help section
  • โŒ Booking cancellation

๐Ÿ› ๏ธ Tech Stack

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

๐Ÿ—๏ธ Architecture

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

๐Ÿงฉ Main Components

๐Ÿค– Telegram API

Handles communication with Telegram using the Bot API.

The bot communicates with Telegram through methods such as:

getUpdates
sendMessage
editMessageText
answerCallbackQuery

๐Ÿ“… Booking System

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

๐Ÿ‘ค Staff Management

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

๐Ÿง  Session Management

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.


๐Ÿ—ƒ๏ธ Data Models

The project currently uses three main data structures.

๐Ÿ’‡ ServiceItem

Represents a barber service.

ID
Name
Duration

๐Ÿ‘ค StaffItem

Represents a barber and the services they provide.

ID
Name
Service IDs

๐Ÿ“… Booking

Represents a customer appointment.

User ID
Username
Vendor ID
Service ID
Staff ID
Date
Time

๐Ÿ–ผ๏ธ Screenshots

๐Ÿ  Main Menu ๐Ÿ’‡ Services ๐Ÿ“… Booking

๐Ÿš€ Getting Started

1๏ธโƒฃ Clone the repository

git clone https://github.com/CodeminTech/telegram_barber_bot.git

2๏ธโƒฃ Navigate to the project

cd telegram_barber_bot

3๏ธโƒฃ Install dependencies

dart pub get

4๏ธโƒฃ Create a Telegram Bot

Open BotFather in Telegram and create a new bot.

Copy the generated Bot Token.

โš ๏ธ Never publish your Bot Token in the repository.

5๏ธโƒฃ Run the bot

dart run -DBOT_TOKEN="YOUR_BOT_TOKEN"

Example:

dart run -DBOT_TOKEN="123456789:YOUR_BOT_TOKEN"

๐Ÿ” Environment Configuration

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.

โš ๏ธ If a real Bot Token has accidentally been committed to GitHub, revoke it and generate a new one through BotFather.


๐Ÿ’พ Data Storage

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.


๐Ÿ“Š Availability System

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.


๐Ÿค– Bot Commands

Command Description
/start ๐Ÿš€ Start the bot
/menu ๐Ÿ  Open the main menu
/bookings ๐Ÿ“‹ View personal bookings
/cancel โŒ Cancel the current booking process

๐ŸŽฏ Project Goals

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

๐Ÿ”ฎ Future Improvements

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

๐Ÿ“ˆ Possible Production Architecture

The current in-memory implementation can later be evolved into a production-ready system:

                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚     Telegram     โ”‚
                    โ”‚      Client      โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                             โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚   Dart Bot API   โ”‚
                    โ”‚     Backend      โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ–ผ              โ–ผ              โ–ผ
        ๐Ÿ‘ค Customers      ๐Ÿ“… Bookings    ๐Ÿ’‡ Staff
              โ”‚              โ”‚              โ”‚
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚     Database     โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ‘ฉโ€๐Ÿ’ป Developer

CodemonTech

Flutter Developer | Mobile Application Developer

๐Ÿ”— GitHub: GitHub: https://github.com/CodeminTech

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages