Build a WhatsApp AI Bot in 2026: whatsapp-web.js (22k Stars) + Baileys - Free Chatbot Without the Business API
Two open-source libraries - whatsapp-web.js (22,341 stars) and Baileys (10,599) - let developers connect AI chatbots to WhatsApp without paying Meta for the Business API, though with some account-risk caveats.
💡 What You Will Learn
Two open-source libraries - whatsapp-web.js (22,341 stars) and Baileys (10,599) - let developers connect AI chatbots to WhatsApp without paying Meta for the Business API, though with some account-risk
📜 Table of Contents
The short answer
whatsapp-web.js (22,341 stars, Apache-2.0) connects to WhatsApp through the Web protocol using Puppeteer - it is the most popular way to build personal WhatsApp bots. Baileys (10,599 stars, MIT) speaks the WhatsApp Web protocol natively in TypeScript, with no browser overhead - faster and more stable for servers.
Quick start with whatsapp-web.js
npm init -y; npm install whatsapp-web.js qrcode-terminal
const { Client, LocalAuth } = require('whatsapp-web.js');
const client = new Client({ authStrategy: new LocalAuth() });
client.on('qr', qr => console.log(qr)); // scan with phone
client.on('ready', () => console.log('Bot online'));
client.on('message', async msg => {
const reply = await askLLM(msg.body); // your LLM call
msg.reply(reply);
});
client.initialize();
Adding the AI part
- Send
msg.bodyto any LLM API (DeepSeek, OpenAI, or local Ollama). - Add a short system prompt: "You are a helpful assistant for a small business..."
- Add rate limiting - one reply per user per 5 seconds to avoid spam bans.
- Keep a per-user conversation window (last 10 messages) so the bot remembers context.
Real numbers and warnings
- whatsapp-web.js has ~2,000 weekly downloads and is actively maintained.
- Unofficial clients risk account bans - Meta can block numbers that automate at scale. Use for personal bots, testing, or with the official Business API for production.
- The official WhatsApp Business API costs per conversation; the open-source route is free but unofficial.
FAQ
Q: Which library should I pick? A: Node.js project with complex auth flows - Baileys. Quickest start with a GUI - whatsapp-web.js. Python-only team - look at the Business API or a Node bridge.
Q: Will Meta ban my number? A: Possibly, if you send high volumes or trigger spam detection. Keep volumes low, avoid mass messaging, and prefer the official API for business-critical use.
❓ FAQ
Which library should I pick?
Node.js project with complex auth flows - Baileys. Quickest start with a GUI - whatsapp-web.js. Python-only team - look at the Business API or a Node bridge.
Will Meta ban my number?
Possibly, if you send high volumes or trigger spam detection. Keep volumes low, avoid mass messaging, and prefer the official API for business-critical use.
Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only โ no paid placements.
