{"slug": "how-i-built-a-whatsapp-ai-bot-that-runs-for-0-month-on-windows", "title": "How I Built a WhatsApp AI Bot That Runs for $0/Month on Windows", "summary": "A developer built a WhatsApp AI bot that runs on a Windows PC with no monthly costs for software, hosting, or AI APIs. The bot uses Node.js and whatsapp-web.js to handle messages, and connects to a locally running Ollama model for AI responses. The project demonstrates a cost-effective approach to building AI-powered chatbots without cloud dependencies.", "body_md": "I wanted a simple WhatsApp AI bot without paying every month for cloud hosting or an AI API.\n\nSo I built one that runs on a Windows PC I already have running 24/7.\n\nThe result:\n\n«The \"$0/month\" refers to additional software, hosting, and AI API costs. It assumes you already have the PC, internet connection, and electricity.»\n\nThe basic architecture\n\nThe setup is intentionally simple:\n\nWhatsApp → Node.js bot → Local AI → WhatsApp reply\n\nThe Node.js application handles incoming WhatsApp messages and decides how to respond.\n\nFor AI responses, the bot can send the user's message to a locally running Ollama model and return the generated answer back to WhatsApp.\n\nThat gives us:\n\nWhatsApp → Node.js → Ollama on localhost → Node.js → WhatsApp\n\nNo cloud AI API is required.\n\nWhat you need\n\nFor the basic setup:\n\nYou don't need Kubernetes.\n\nYou don't need AWS.\n\nYou don't need Docker.\n\nAnd you don't need to rent a VPS.\n\nConnecting WhatsApp\n\nFor this project I used \"whatsapp-web.js\".\n\nThe first time the application starts, it displays a QR code.\n\nYou scan the QR code with WhatsApp, similar to connecting WhatsApp Web.\n\nAfter authentication, the application can listen for incoming messages and send replies.\n\nA simplified example looks like this:\n\nconst { Client, LocalAuth } = require('whatsapp-web.js');\n\nconst client = new Client({\n\nauthStrategy: new LocalAuth()\n\n});\n\nclient.on('qr', (qr) => {\n\nconsole.log('Scan the QR code to connect WhatsApp');\n\n});\n\nclient.on('ready', () => {\n\nconsole.log('WhatsApp bot is ready');\n\n});\n\nclient.on('message', async (message) => {\n\nif (message.body.toLowerCase() === 'hello') {\n\nawait message.reply('Hello from the bot!');\n\n}\n\n});\n\nclient.initialize();\n\n\"LocalAuth\" stores the authenticated WhatsApp session locally.\n\nThat means you normally don't need to scan the QR code again every time the application restarts.\n\nProtect the WhatsApp session\n\nThe authentication files should be treated like credentials.\n\nDo not:\n\nAdd sensitive files and directories to \".gitignore\".\n\nFor example:\n\n.env\n\n.wwebjs_auth/\n\n.wwebjs_cache/\n\nnode_modules/\n\nAdding local AI with Ollama\n\nThe next step is connecting the bot to Ollama.\n\nOllama runs the language model locally on the Windows machine.\n\nInstead of calling a paid cloud API, Node.js sends the prompt to Ollama on localhost.\n\nA simplified request might look like this:\n\nasync function askOllama(prompt) {\n\nconst response = await fetch('[http://localhost:11434/api/generate](http://localhost:11434/api/generate)', {\n\nmethod: 'POST',\n\nheaders: {\n\n'Content-Type': 'application/json'\n\n},\n\nbody: JSON.stringify({\n\nmodel: 'llama3.2',\n\nprompt,\n\nstream: false\n\n})\n\n});\n\nconst data = await response.json();\n\nreturn data.response;\n\n}\n\nThen the WhatsApp handler can use it:\n\nclient.on('message', async (message) => {\n\ntry {\n\nconst answer = await askOllama(message.body);\n\nawait message.reply(answer);\n\n} catch (error) {\n\nconsole.error(error);\n\nawait message.reply('Something went wrong.');\n\n}\n\n});\n\nNow the flow becomes:\n\nChoosing a local model\n\nThe model you can run comfortably depends on the hardware.\n\nSmaller models generally:\n\nLarger models can provide better results for some tasks, but they require more resources.\n\nFor a small personal bot or learning project, starting with a relatively small model is usually the easiest approach.\n\nKeeping the bot running\n\nDuring development, you can simply run:\n\nnode index.js\n\nBut that isn't enough for a machine that should host the bot continuously.\n\nYou want the application to:\n\nOne option is using PM2:\n\nnpm install -g pm2\n\nThen:\n\npm2 start index.js --name whatsapp-ai-bot\n\nYou can check its status with:\n\npm2 status\n\nAnd view logs with:\n\npm2 logs whatsapp-ai-bot\n\nFor a long-running Windows setup, make sure you also configure a reliable startup mechanism so the process returns after a machine reboot.\n\nWhat can you build with it?\n\nOnce the basic connection works, you can extend the bot in many directions:\n\nThe WhatsApp connection is really just the interface.\n\nThe interesting part is what you put behind it.\n\nA note about whatsapp-web.js\n\n\"whatsapp-web.js\" is an unofficial integration that works through WhatsApp Web.\n\nIt is not the official WhatsApp Business Platform.\n\nThat 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.\n\nFor an official commercial integration, the WhatsApp Business Platform is the appropriate route to evaluate.\n\nWhy I built this\n\nI wanted something that didn't require a cloud account, recurring hosting bill, or complicated infrastructure.\n\nA Windows machine that was already online could do the job.\n\nFor a developer, the setup is relatively straightforward.\n\nBut 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.\n\nComplete step-by-step version\n\nI created a downloadable guide that includes the full Windows setup and ready-to-run project files.\n\nIt covers:\n\nYou can find it here:\n\nIf you build your own version, I'd be interested to hear what you're using your WhatsApp bot for.", "url": "https://wpnews.pro/news/how-i-built-a-whatsapp-ai-bot-that-runs-for-0-month-on-windows", "canonical_source": "https://dev.to/zerocosttech/how-i-built-a-whatsapp-ai-bot-that-runs-for-0month-on-windows-4kig", "published_at": "2026-08-15 21:37:11+00:00", "updated_at": "2026-08-15 21:41:45.485564+00:00", "lang": "en", "topics": ["artificial-intelligence", "developer-tools", "ai-tools"], "entities": ["WhatsApp", "Node.js", "Ollama", "whatsapp-web.js", "PM2"], "alternates": {"html": "https://wpnews.pro/news/how-i-built-a-whatsapp-ai-bot-that-runs-for-0-month-on-windows", "markdown": "https://wpnews.pro/news/how-i-built-a-whatsapp-ai-bot-that-runs-for-0-month-on-windows.md", "text": "https://wpnews.pro/news/how-i-built-a-whatsapp-ai-bot-that-runs-for-0-month-on-windows.txt", "jsonld": "https://wpnews.pro/news/how-i-built-a-whatsapp-ai-bot-that-runs-for-0-month-on-windows.jsonld"}}