A comprehensive Telegram Bot for managing Tire Service workflows.
Developed for a service station in Dnipro, Ukraine πΊπ¦
This bot is designed to automate and streamline the operations of a tire service station. It includes a robust order management system, role-based access control for employees (Admins, Masters), and customer-facing features like warranty verification via QR codes.
It efficiently handles the entire lifecycle of a service order, from creation to completion, generating PDF warranty certificates, and tracking performance statistics.
- Order Management: Create, track, and update service orders in real-time.
- Role-Based Access Control (RBAC):
- ADMIN: Full system control, analytics, and order management.
- MASTER: Manage assigned orders and view personal stats.
- USER (Customer): Verify warranties and check current order status.
- Warranty Verification: Generate unique QR codes for orders. Customers can scan to verify warranty validity instantly.
- PDF Generation: Automatic generation of warranty certificates (PDF) with sending via Email/Telegram.
- Google Sheets Integration: Sync staff data and backup order history automatically.
- Search & Reporting: Advanced search by phone number and detailed statistics summaries.
- Framework: NestJS (Node.js)
- Language: TypeScript
- Database: PostgreSQL with Prisma ORM
- Bot API:
telegraf - PDF Generation:
pdf-lib - Integrations: Google Sheets API (
google-spreadsheet), Nodemailer - Containerization: Docker & Docker Compose
- Node.js (v20+)
- Docker & Docker Compose
- PostgreSQL (if running locally without Docker)
- A Telegram Bot Token (from @BotFather)
- Google Service Account Credentials (for Sheets integration)
-
Clone the repository
git clone https://github.com/horoshi10v/tire-service-bot cd tire-service-bot -
Install dependencies
npm install
-
Configure Environment Variables
Copy the example configuration file and update it with your credentials:
cp .env.example .env
Make sure to fill in your Telegram Bot Token, Database URL, and Google Credentials.
# Start the database (if using Docker for DB only)
docker-compose up db -d
# Run migrations
npx prisma migrate dev
# Start the app
npm run start:devdocker-compose up -d --buildThe application will start, and the bot will be ready to accept commands.
Menu Buttons:
| Button | Description |
|---|---|
π ΠΠΎΠ²ΠΈΠΉ |
Create a new order (starts by uploading a photo) |
π ΠΠΎΡΡΠΊ |
Interactive search by phone number |
π ΠΡΠ΄ΠΊΡΠΈΡΠΈ Π·Π°ΠΌΠΎΠ²Π»Π΅Π½Π½Ρ |
Open an order by ID |
π Π‘ΡΠ°ΡΠΈΡΡΠΈΠΊΠ° |
Show current order statistics |
π‘ ΠΡΠΈΠΉΠ½ΡΡΡ |
List orders with status Accepted |
π΅ Π ΡΠΎΠ±ΠΎΡΡ |
List orders with status In Progress |
π’ ΠΠΎΡΠΎΠ²Ρ |
List orders with status Ready |
β« ΠΠΈΠ΄Π°Π½Ρ |
List orders with status Done |
Text Commands:
| Command | Description | Access |
|---|---|---|
/start |
Open the main menu | All |
/active <id> |
Open a specific order by ID | Master, Admin |
/search |
Search for an order by phone number | Master, Admin |
/edit <id> |
Edit an existing order | Master, Admin |
/delete <id> CONFIRM |
Delete an order permanently | Admin only |
/backup |
Backup all orders to Google Sheets | Admin only |
/sync_staff |
Sync staff list from Google Sheets | Admin only |
/restore CONFIRM |
Restore orders from Backup sheet | Admin only |
| Command / Button | Description |
|---|---|
/start verify_<token> |
Verify a warranty certificate (usually scanned via QR) |
π Π‘ΡΠ°ΡΡΡ Π·Π°ΠΌΠΎΠ²Π»Π΅Π½Π½Ρ |
Check the status of your current order |
Roles (ADMIN, MASTER) are managed in the database or synchronized via the Google Sheets integration.
Initially, you may need to insert the first Admin manually into the database:
INSERT INTO "Employee" ("tgId", "name", "role", "isActive")
VALUES (YOUR_TELEGRAM_ID, 'Admin Name', 'ADMIN', true);src/
βββ common/ # Domain logic, events, guards, & exceptions
βββ config/ # Environment configuration
βββ modules/
β βββ auth/ # Authentication service
β βββ bot/ # Telegram bot logic (Commands, Handlers, Flows)
β βββ integrations/ # External APIs (Google Sheets)
β βββ mail/ # Email sending service
β βββ notifications/ # Notification strategies
β βββ orders/ # Order business logic & CRUD
β βββ pdf/ # PDF generation (Fonts, Icons, Generators)
β βββ warranty/ # Warranty verification logic
βββ prisma/ # Database connection & schema
βββ main.ts # Application entry pointThis project is licensed under the MIT License.