A WhatsApp AI bot with Gemini integration, optimized for Vercel serverless deployment.
- 🤖 AI-powered responses using Google Gemini
- 📱 WhatsApp Web integration
- 🔄 Multi-API key support with automatic fallback
- 📚 Knowledge base management
- 🌐 Web dashboard for management
- ☁️ Serverless deployment on Vercel
-
Prepare the project:
- Ensure all files are in the
whatsapp-bot-verceldirectory - Verify
vercel.jsonconfiguration is correct
- Ensure all files are in the
-
Deploy to Vercel:
- Go to vercel.com
- Click "New Project"
- Upload the
whatsapp-bot-vercelfolder - Set Framework Preset: Other
- Set Root Directory: .
- Click Deploy
-
Push to GitHub:
cd whatsapp-bot-vercel git init git add . git commit -m "Initial commit" git remote add origin YOUR_GITHUB_REPO_URL git push -u origin main
-
Connect to Vercel:
- Go to vercel.com
- Click "New Project"
- Import from GitHub
- Select your repository
- Framework Preset: Other
- Root Directory: .
- Deploy
You can set these in Vercel dashboard under Settings > Environment Variables:
GEMINI_API_KEY_1: Primary Gemini API keyGEMINI_API_KEY_2: Backup Gemini API keyGEMINI_API_KEY_3: Second backup Gemini API key
- Get your Gemini API keys from Google AI Studio
- Access your deployed dashboard
- Navigate to the Knowledge Base section
- Enter your API keys in the dashboard
-
Access Dashboard:
- Visit your Vercel deployment URL
- You'll see the WhatsApp Bot Dashboard
-
Start the Bot:
- Click "Start Bot" in the dashboard
- Scan the QR code with WhatsApp
- Bot is now ready to receive messages
-
Manage Knowledge Base:
- Use the dashboard to update the bot's knowledge
- Save changes to apply them immediately
- Serverless Functions: Each request has a 30-second timeout
- Stateless: WhatsApp session may not persist between requests
- Cold Starts: First request may be slower
- File Storage: Limited to
/tmpdirectory (temporary)
For production use, consider these platforms that better support persistent connections:
- Railway:
railway.app- Better for persistent Node.js apps - Render:
render.com- Good for Express.js applications - Fly.io:
fly.io- Excellent for containerized apps - Heroku:
heroku.com- Classic choice for Node.js apps
-
QR Code Not Loading:
- Check Vercel function logs
- Ensure WhatsApp Web dependencies are installed
- Try refreshing the page
-
API Key Errors:
- Verify API keys are correct
- Check Gemini API quotas
- Test keys in the dashboard
-
Session Issues:
- WhatsApp sessions may not persist on Vercel
- You may need to scan QR code frequently
- Consider using a persistent platform for production
- Check Vercel function logs in the dashboard
- Use browser developer tools for client-side issues
- Monitor the activity log in the bot dashboard
whatsapp-bot-vercel/
├── api/
│ └── index.js # Main serverless function
├── public/
│ └── index.html # Dashboard interface
├── KB/
│ └── kb.txt # Knowledge base content
├── vercel.json # Vercel configuration
├── package.json # Dependencies
├── geminiHandler.js # AI handler
└── README.md # This file
For issues and questions:
- Check the troubleshooting section above
- Review Vercel deployment logs
- Test with a simpler deployment first
MIT License - see LICENSE file for details.