# Hybrid MeetMe Bot Setup Guide ## Overview This guide sets up a complete hybrid solution combining: - **Node.js Backend**: [MeetMe API](https://github.com/Andyss4545/meetme-backend-api) for robust API infrastructure - **Python Bots**: Enhanced automation with AI integration - **Local Development**: Full testing environment - **Production Ready**: Scalable deployment options ## πŸ—οΈ Architecture ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Python Bots β”‚ β”‚ Node.js API β”‚ β”‚ MongoDB DB β”‚ β”‚ │◄──►│ │◄──►│ β”‚ β”‚ β€’ Ice Breaker β”‚ β”‚ β€’ User Mgmt β”‚ β”‚ β€’ User Data β”‚ β”‚ β€’ Auto Responderβ”‚ β”‚ β€’ Messages β”‚ β”‚ β€’ Messages β”‚ β”‚ β€’ AI Integrationβ”‚ β”‚ β€’ Conversations β”‚ β”‚ β€’ Analytics β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` ## πŸ“‹ Prerequisites ### System Requirements - **Node.js 16+** with npm - **Python 3.8+** with pip - **MongoDB 4.4+** installed and running - **Git** for cloning repositories - **Ollama** for AI integration ### Windows Setup ```powershell # Install Node.js (if not installed) winget install OpenJS.NodeJS # Install Python (if not installed) winget install Python.Python.3.11 # Install MongoDB winget install MongoDB.Server # Install Ollama winget install Ollama.Ollama ``` ## πŸš€ Step-by-Step Setup ### Phase 1: Node.js Backend Setup #### 1.1 Clone and Configure Backend ```bash # Clone the MeetMe backend repository git clone https://github.com/Andyss4545/meetme-backend-api.git cd meetme-backend-api # Install dependencies npm install ``` #### 1.2 Configure Environment Create `.env` file in the backend directory: ```env # Server Configuration PORT=3000 NODE_ENV=development # MongoDB Configuration MONGODB_URI=mongodb://localhost:27017/meetme_dev # JWT Configuration JWT_SECRET=your_super_secret_jwt_key_here JWT_EXPIRES_IN=7d # API Configuration API_BASE_URL=http://localhost:3000/api/v1 CORS_ORIGIN=http://localhost:3000 # Bot Configuration BOT_RATE_LIMIT=100 BOT_TIMEOUT=30000 ``` #### 1.3 Start Backend Server ```bash # Development mode with auto-reload npm run dev # Or production mode npm start ``` #### 1.4 Verify Backend ```bash # Test health endpoint curl http://localhost:3000/api/v1/health # Create test user curl -X POST http://localhost:3000/api/v1/users \ -H "Content-Type: application/json" \ -d '{ "username": "testuser", "email": "test@example.com", "password": "password123" }' ``` ### Phase 2: Python Bot Setup #### 2.1 Setup Python Environment ```powershell # Create virtual environment python -m venv venv venv\Scripts\activate # Install dependencies pip install -r requirements.txt ``` #### 2.2 Configure Bot Environment Copy `env_template_enhanced.txt` to `.env` and configure: **For Local Development:** ```env USE_LOCAL_API=true API_BASE_URL=http://localhost:3000/api/v1 API_USERNAME=testuser API_PASSWORD=password123 ``` **For Production:** ```env USE_LOCAL_API=false API_BASE_URL=https://api.meetme.com MM_USERNAME=your_meetme_email MM_PASSWORD=your_meetme_password ``` #### 2.3 Setup Ollama ```bash # Pull the AI model ollama pull quen3 # Start Ollama service ollama serve quen3 ``` ### Phase 3: Testing and Validation #### 3.1 Test Local API ```bash # Test backend endpoints curl http://localhost:3000/api/v1/users curl http://localhost:3000/api/v1/conversations ``` #### 3.2 Test Python Bots ```powershell # Test ice breaker bot python enhanced_icebreaker_bot.py # Test responder bot python enhanced_responder_bot.py ``` #### 3.3 Monitor Logs ```bash # Check bot activity tail -f bot_activity.log # Check backend logs npm run dev ``` ## πŸ”§ Advanced Configuration ### Custom API Endpoints Add custom endpoints to the Node.js backend for bot-specific features: ```javascript // In routes/bot.js router.get('/bot/stats', botController.getBotStats); router.post('/bot/message', botController.sendBotMessage); router.get('/bot/conversations', botController.getBotConversations); ``` ### Enhanced Security ```env # Rate limiting RATE_LIMIT_ENABLED=true MAX_REQUESTS_PER_MINUTE=100 # Authentication JWT_SECRET=your_very_secure_jwt_secret JWT_EXPIRES_IN=7d # Bot restrictions MAX_MESSAGES_PER_SESSION=20 MESSAGE_DELAY=60 ``` ### Database Optimization ```javascript // MongoDB indexes for better performance db.users.createIndex({ "location": "2dsphere" }); db.messages.createIndex({ "conversation_id": 1, "timestamp": -1 }); db.conversations.createIndex({ "participants": 1 }); ``` ## πŸš€ Production Deployment ### Option 1: Cloud Deployment ```bash # Deploy Node.js backend to Heroku heroku create meetme-bot-backend git push heroku main # Deploy Python bots to Railway railway login railway init railway up ``` ### Option 2: Docker Deployment ```dockerfile # Dockerfile for Node.js backend FROM node:16-alpine WORKDIR /app COPY package*.json ./ RUN npm install COPY . . EXPOSE 3000 CMD ["npm", "start"] ``` ### Option 3: Local Production ```bash # Use PM2 for process management npm install -g pm2 pm2 start server.js --name "meetme-backend" pm2 start enhanced_icebreaker_bot.py --name "ice-breaker-bot" pm2 start enhanced_responder_bot.py --name "responder-bot" ``` ## πŸ“Š Monitoring and Analytics ### Bot Statistics - Message count per conversation - Response time metrics - User engagement tracking - AI response quality analysis ### System Health - API response times - Database performance - Memory usage - Error rates ### Log Analysis ```bash # Analyze bot activity grep "ERROR" bot_activity.log grep "Successfully sent" bot_activity.log | wc -l ``` ## πŸ”’ Security Best Practices ### Environment Security - Never commit `.env` files - Use strong, unique passwords - Rotate JWT secrets regularly - Implement rate limiting ### Bot Security - Monitor bot behavior - Set message limits - Implement cooldown periods - Log all activities ### API Security - Validate all inputs - Sanitize user data - Implement CORS properly - Use HTTPS in production ## πŸ› Troubleshooting ### Common Issues **Backend Connection Issues:** ```bash # Check MongoDB mongo --eval "db.adminCommand('ping')" # Check Node.js server curl -v http://localhost:3000/api/v1/health # Check logs npm run dev ``` **Bot Authentication Issues:** ```bash # Verify credentials echo $API_USERNAME echo $API_PASSWORD # Test login manually curl -X POST http://localhost:3000/api/v1/auth/login \ -H "Content-Type: application/json" \ -d '{"email":"testuser","password":"password123"}' ``` **Ollama Integration Issues:** ```bash # Check Ollama service curl http://10.30.20.110:11434/v1/models # Test model response curl -X POST http://10.30.20.110:11434/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{"model":"quen3","messages":[{"role":"user","content":"Hello"}]}' ``` ## πŸ“ˆ Performance Optimization ### Database Optimization - Index frequently queried fields - Use connection pooling - Implement caching strategies ### API Optimization - Implement pagination - Use compression - Cache static responses ### Bot Optimization - Batch API requests - Implement retry logic - Use async processing ## 🎯 Next Steps 1. **Customize Bot Personality**: Modify prompts and responses 2. **Add Analytics**: Implement detailed tracking 3. **Scale Infrastructure**: Add load balancing and clustering 4. **Enhance AI**: Integrate multiple AI models 5. **Add Features**: Implement advanced conversation management ## πŸ“ž Support For issues and questions: - Check the [Node.js API repository](https://github.com/Andyss4545/meetme-backend-api) - Review bot logs for error details - Test individual components separately - Verify all environment variables are set correctly