5 Problems I Hit Running a WhatsApp AI Bot 24/7 on Windows - And How I Fixed Them
DEV Community

5 Problems I Hit Running a WhatsApp AI Bot 24/7 on Windows - And How I Fixed Them

Running a WhatsApp AI bot locally sounds simple: WhatsApp → Node.js → Ollama → done. In practice, keeping it running reliably 24/7 on a Windows PC taught me a few things the hard way. Here are 5 problems I ran into - and how I fixed them. 1. The bot stopped when the terminal closed During development, running node index.js worked perfectly. But the moment the terminal was closed, the bot disappeared with it. The fix Use a process manager such as PM2: npm install -g pm2 Then: pm2 start index.js --name whatsapp-ai-bot And save the process list: pm2 save This makes the bot much easier to manage and restart. 2. WhatsApp kept asking me to scan the QR code Scanning a QR code every time the bot starts isn't practical for a machine that's supposed to run 24/7. The fix With whatsapp-web.js , use persistent local authentication: const { Client, LocalAuth } = require('whatsapp-web.js'); const client = new Client({ authStrategy: new LocalAuth() }); The authentication session is stored locally, so normal restarts don't require pairing the account again. 3. Ollama worked - but responses were painfully slow A local LLM means no paid AI API, but your hardware now does the inference. Running a model that's too large can make a WhatsApp bot feel unusable. The fix Start with a smaller model. For example: ollama run llama3.2:3b Then test response time before moving to something larger. For a chat bot, a fast smaller model can be more useful than a smarter model that takes forever to answer. 4. One failure could crash the whole bot Network requests fail. Ollama may temporarily be unavailable. Messages may contain unexpected content. Without error handling, one bad request can take down a bot that's supposed to run unattended. The fix Treat every external operation as something that can fail. For example: try { const response = await askOllama(message.body); await message.reply(response); } catch (error) { console.error('Bot error:', error); } Also log failures instead of silently ignoring them. 5. "$0/month" doesn't mean "zero resources" This was an important distinction. The setup can avoid: - VPS hosting fees - Paid AI API fees - Cloud compute bills But the Windows machine still needs to remain powered on and connected to the internet. For me, that's the useful part of this architecture: reuse hardware you already own instead of paying for another server every month. The final setup The architecture ended up being surprisingly small: WhatsApp → whatsapp-web.js → Node.js → Ollama → Local LLM No VPS. No paid AI API. No monthly hosting subscription. If you want the complete Windows setup, source code, configuration, and step-by-step instructions, I put everything together here: ๐Ÿ‘‰ Complete WhatsApp AI Bot Setup Guide + Code If you're building something similar, I'd also be interested to hear what problems you ran into. Top comments (0)

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.