3.1 KiB
3.1 KiB
Yaltopia Telegram Bot
A feature-rich Telegram bot for property listings built with TypeScript and organized using a feature-first architecture.
Features
- 📱 Phone-based Authentication: Users share phone number to login/register
- 🏠 Property Management: Browse, view, and add properties
- 👤 User Registration: Complete registration flow with validation
- 🔐 Secure Login: Password-based authentication for existing users
- 📋 Property Listings: View all available properties
- 🏘️ My Properties: Manage user's own property listings
Architecture
This project follows a feature-first approach for better scalability:
src/
├── shared/ # Shared utilities and services
│ ├── types/ # Common TypeScript interfaces
│ └── services/ # Shared services (API, Session)
├── features/ # Feature modules
│ ├── auth/ # Authentication feature
│ └── properties/ # Property management feature
└── bot/ # Bot orchestration
Setup
-
Install dependencies:
npm install -
Environment setup:
cp .env.example .envEdit
.envand add your Telegram bot token:TELEGRAM_BOT_TOKEN=your_bot_token_here API_BASE_URL=http://localhost:3000/api -
Build the project:
npm run build -
Start the bot:
npm startFor development:
npm run dev
Bot Flow
1. Authentication Flow
- User starts with
/start - Bot requests phone number
- If phone exists → Login with password
- If new user → Registration flow (name, email, password, confirm)
2. Main Menu (After Login)
- 🏘️ Browse Properties: View all available properties
- 🏠 My Properties: View user's own listings
- ➕ Add Property: Create new property listing
- 👤 Profile: View user profile information
3. Property Creation Flow
- Title → Description → Type (Rent/Sale) → Price → Area → Rooms → Toilets → Subcity → House Type
API Integration
The bot integrates with your existing backend APIs:
POST /telegram-auth/telegram-register- User registrationPOST /telegram-auth/telegram-login- User loginGET /telegram-auth/phone/{phone}/check- Check phone existenceGET /telegram-auth/validate-email/{email}- Email validationGET /listings- Get all propertiesPOST /listings- Create new property
Development
Scripts
npm run build- Compile TypeScriptnpm run dev- Run in development mode with ts-nodenpm run watch- Watch mode for TypeScript compilationnpm start- Run compiled JavaScript
Adding New Features
- Create feature directory in
src/features/ - Add service class for API interactions
- Add handler class for bot interactions
- Integrate in main bot class (
src/bot/bot.ts)
Getting Your Bot Token
- Message @BotFather on Telegram
- Use
/newbotcommand - Follow the setup process
- Copy the token to your
.envfile