# How I Built a WhatsApp AI Bot That Runs for $0/Month on Windows

> Source: <https://dev.to/zerocosttech/how-i-built-a-whatsapp-ai-bot-that-runs-for-0month-on-windows-4kig>
> Published: 2026-08-15 21:37:11+00:00

I wanted a simple WhatsApp AI bot without paying every month for cloud hosting or an AI API.

So I built one that runs on a Windows PC I already have running 24/7.

The result:

«The "$0/month" refers to additional software, hosting, and AI API costs. It assumes you already have the PC, internet connection, and electricity.»

The basic architecture

The setup is intentionally simple:

WhatsApp → Node.js bot → Local AI → WhatsApp reply

The Node.js application handles incoming WhatsApp messages and decides how to respond.

For AI responses, the bot can send the user's message to a locally running Ollama model and return the generated answer back to WhatsApp.

That gives us:

WhatsApp → Node.js → Ollama on localhost → Node.js → WhatsApp

No cloud AI API is required.

What you need

For the basic setup:

You don't need Kubernetes.

You don't need AWS.

You don't need Docker.

And you don't need to rent a VPS.

Connecting WhatsApp

For this project I used "whatsapp-web.js".

The first time the application starts, it displays a QR code.

You scan the QR code with WhatsApp, similar to connecting WhatsApp Web.

After authentication, the application can listen for incoming messages and send replies.

A simplified example looks like this:

const { Client, LocalAuth } = require('whatsapp-web.js');

const client = new Client({

authStrategy: new LocalAuth()

});

client.on('qr', (qr) => {

console.log('Scan the QR code to connect WhatsApp');

});

client.on('ready', () => {

console.log('WhatsApp bot is ready');

});

client.on('message', async (message) => {

if (message.body.toLowerCase() === 'hello') {

await message.reply('Hello from the bot!');

}

});

client.initialize();

"LocalAuth" stores the authenticated WhatsApp session locally.

That means you normally don't need to scan the QR code again every time the application restarts.

Protect the WhatsApp session

The authentication files should be treated like credentials.

Do not:

Add sensitive files and directories to ".gitignore".

For example:

.env

.wwebjs_auth/

.wwebjs_cache/

node_modules/

Adding local AI with Ollama

The next step is connecting the bot to Ollama.

Ollama runs the language model locally on the Windows machine.

Instead of calling a paid cloud API, Node.js sends the prompt to Ollama on localhost.

A simplified request might look like this:

async function askOllama(prompt) {

const response = await fetch('[http://localhost:11434/api/generate](http://localhost:11434/api/generate)', {

method: 'POST',

headers: {

'Content-Type': 'application/json'

},

body: JSON.stringify({

model: 'llama3.2',

prompt,

stream: false

})

});

const data = await response.json();

return data.response;

}

Then the WhatsApp handler can use it:

client.on('message', async (message) => {

try {

const answer = await askOllama(message.body);

await message.reply(answer);

} catch (error) {

console.error(error);

await message.reply('Something went wrong.');

}

});

Now the flow becomes:

Choosing a local model

The model you can run comfortably depends on the hardware.

Smaller models generally:

Larger models can provide better results for some tasks, but they require more resources.

For a small personal bot or learning project, starting with a relatively small model is usually the easiest approach.

Keeping the bot running

During development, you can simply run:

node index.js

But that isn't enough for a machine that should host the bot continuously.

You want the application to:

One option is using PM2:

npm install -g pm2

Then:

pm2 start index.js --name whatsapp-ai-bot

You can check its status with:

pm2 status

And view logs with:

pm2 logs whatsapp-ai-bot

For a long-running Windows setup, make sure you also configure a reliable startup mechanism so the process returns after a machine reboot.

What can you build with it?

Once the basic connection works, you can extend the bot in many directions:

The WhatsApp connection is really just the interface.

The interesting part is what you put behind it.

A note about whatsapp-web.js

"whatsapp-web.js" is an unofficial integration that works through WhatsApp Web.

It is not the official WhatsApp Business Platform.

That makes it convenient for experiments and personal projects, but it also means you should understand the trade-offs before using it for a business-critical or production system.

For an official commercial integration, the WhatsApp Business Platform is the appropriate route to evaluate.

Why I built this

I wanted something that didn't require a cloud account, recurring hosting bill, or complicated infrastructure.

A Windows machine that was already online could do the job.

For a developer, the setup is relatively straightforward.

But there were enough small steps — Node.js setup, WhatsApp authentication, Ollama, configuration, persistent startup, and troubleshooting — that I decided to package the complete process into a beginner-friendly guide.

Complete step-by-step version

I created a downloadable guide that includes the full Windows setup and ready-to-run project files.

It covers:

You can find it here:

If you build your own version, I'd be interested to hear what you're using your WhatsApp bot for.
