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.
During development, running node index.js worked perfectly.
But the moment the terminal was closed, the bot disappeared with it.
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.
Scanning a QR code every time the bot starts isn't practical for a machine that's supposed to run 24/7.
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.
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.
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. 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.
Treat every external operation as something that can fail.
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.
This was an important distinction.
The setup can avoid:
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 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.