A complete e-commerce Telegram bot for Vidoma - home and sleepwear store. Features AI-powered customer consultation, automated order processing, CRM integration, and comprehensive back navigation.
- AI-Powered Consultation - OpenAI GPT-4 integration for product recommendations
- Smart Navigation - Complete back button logic throughout the bot
- Product Catalog - Browse by categories with product images and details
- Size Assistant - Interactive size guide and recommendations
- Order Processing - Multi-step order collection with validation
- Order Tracking - Check delivery status via phone/TTN
- Customer Support - Direct messaging to managers
- Ukrainian Language - Fully localized for Ukrainian customers
- Product Management - Add, edit, delete products
- CSV Import/Export - Bulk product management
- Order Management - View and process orders
- Category Management - Organize product hierarchy
- Customer Support - Manage customer inquiries
- Analytics Dashboard - Sales and user statistics
- SalesDrive CRM - Automatic order submission
- OpenAI GPT-4 - AI customer consultation
- Nova Poshta API - Delivery tracking (ready for integration)
- SQLite Database - Lightweight data storage
- Node.js 16+
- npm 8+
- Telegram Bot Token (Get from @BotFather)
- OpenAI API Key (Get from OpenAI)
# Clone repository
git clone https://github.com/your-repo/vidoma-bot.git
cd vidoma-bot
# Install dependencies
npm install
# Run setup wizard
npm run setupThe setup wizard will guide you through configuration, or manually edit .env:
# Required configurations
TELEGRAM_BOT_TOKEN=your_bot_token
OPENAI_API_KEY=your_openai_key
CRM_API_KEY=your_crm_key (provided)Place your products.csv file in the data/ folder:
# Import products from CSV
npm run import-csvCSV format:
post_title,sku,regular_price,sale_price,categories,post_content,stock,images
"Product Name","SKU123",1200,1000,"Category","Description",10,"[""image1.jpg""]"
# Start the bot
npm start
# Or with auto-reload during development
npm run dev
# Start admin panel (separate terminal)
npm run admin- Start -
/startcommand shows welcome message - Browse Products - View categories and products
- AI Consultation - Ask questions about products
- Order Process - Multi-step order collection:
- Product selection
- Customer name
- Phone number
- Delivery address
- Payment method
- Order confirmation
- Order Tracking - Check status via phone/TTN
- Customer Support - Contact manager directly
Access at http://localhost:3000:
- Username:
admin - Password:
admin123(configurable)
Features:
- Product management
- Order processing
- Customer inquiries
- Analytics dashboard
vidoma-bot/
├── src/
│ ├── bot/ # Telegram Bot Components
│ │ ├── handlers/ # Message handlers
│ │ ├── keyboards/ # Keyboard layouts
│ │ ├── messages/ # Ukrainian messages
│ │ └── scenes/ # Multi-step flows
│ ├── services/ # Business Logic
│ │ ├── ai.js # OpenAI integration
│ │ ├── crm.js # SalesDrive CRM
│ │ ├── product.js # Product operations
│ │ └── csv.js # CSV import/export
│ ├── database/ # Database Layer
│ └── admin/ # Admin Panel (future)
├── data/ # Data Storage
│ ├── database.sqlite # SQLite database
│ ├── products.csv # Product import file
│ └── uploads/ # Image uploads
├── scripts/ # Utility Scripts
└── logs/ # Application logs
| Variable | Description | Required |
|---|---|---|
TELEGRAM_BOT_TOKEN |
Bot token from @BotFather | ✅ |
OPENAI_API_KEY |
OpenAI API key | ✅ |
CRM_API_KEY |
SalesDrive CRM key | ✅ |
ADMIN_CHAT_ID |
Admin Telegram ID for notifications | ❌ |
ADMIN_PASSWORD |
Admin panel password | ❌ |
AI_ENABLED=true # Enable AI consultation
CRM_ENABLED=true # Enable CRM integration
CSV_IMPORT_ENABLED=true # Enable CSV import
ADMIN_PANEL_ENABLED=true # Enable admin panel/start- Start the bot/help- Show help information- Browse Products - View product catalog
- Order Status - Track delivery
- Contact Manager - Customer support
/stats- User and order statistics/orders- Recent orders/inquiries- Customer messages
- products - Product catalog
- categories - Product categories
- orders - Customer orders
- order_items - Order details
- users - Bot users
- customer_inquiries - Support messages
The bot implements comprehensive back navigation:
// Navigation stack tracks user journey
ctx.session.navigationStack = [
{ type: 'main_menu' },
{ type: 'categories' },
{ type: 'category_products', categoryId: 1 },
{ type: 'product_details', productId: 123 }
];
// Back button returns to previous state
ctx.goBack() // Returns to category_productsStates handled:
main_menu- Main bot menucategories- Category selectioncategory_products- Products in categoryproduct_details- Product informationsize_help- Size assistanceorder_flow- Order process steps
The bot uses OpenAI GPT-4 for customer consultation:
// AI consultation example
User: "Мені потрібна піжама для сну"
AI: "Рекомендую переглянути нашу колекцію піжам!
У нас є комфортні костюми з м'яких тканин.
🛍️ Переглянути піжами в каталозі"AI capabilities:
- Product recommendations
- Size consultation
- Style advice
- General assistance
- Fallback responses
- Product Selection - Choose item and size
- Customer Info - Name and phone validation
- Delivery - Address and Nova Poshta details
- Payment - Method selection
- Confirmation - Order summary
- CRM Submission - Automatic processing
- Confirmation - Success message
- Bank transfer
- Cash on delivery
- Nova Poshta (warehouse pickup)
- Nova Poshta (courier delivery)
npm run dev # Auto-reload on changesnpm test # Run test suitenpm run import-csv # Import products from data/products.csvLogs are written to logs/ directory:
error.log- Error messagescombined.log- All messages- Console output during development
- Set
NODE_ENV=production - Configure webhook (optional)
- Set up SSL certificates
- Configure admin notifications
- Set up monitoring
WEBHOOK_DOMAIN=yourdomain.com
WEBHOOK_PORT=8443
WEBHOOK_PATH=/webhook# Using PM2
pm2 start bot.js --name vidoma-bot
pm2 start server.js --name vidoma-admin- Input validation on all user inputs
- Rate limiting on API calls
- Secure session management
- CORS protection
- SQL injection prevention
- Admin authentication
- User registrations
- Active users
- Order conversions
- Popular products
- AI consultation usage
- Error rates
- Database connectivity
- CRM API status
- OpenAI API status
- Bot responsiveness
Bot not responding:
# Check bot token
node -e "console.log(process.env.TELEGRAM_BOT_TOKEN)"
# Test bot connection
curl "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/getMe"Database errors:
# Reinitialize database
rm data/database.sqlite
npm start # Will recreate tablesCRM integration issues:
# Test CRM connection
node -e "
const crm = require('./src/services/crm');
crm.testConnection().then(console.log);
"# View recent errors
tail -f logs/error.log
# Search for specific issues
grep "CRM" logs/combined.log- Fork the repository
- Create feature branch
- Make changes
- Test thoroughly
- Submit pull request
MIT License - see LICENSE file.
- 📧 Email: [email protected]
- 💬 Telegram: @vidoma_support
- 🐛 Issues: GitHub Issues
Ready to launch your Vidoma bot! 🚀
Start with npm run setup and follow the wizard.