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
## 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
```bash
npm init -y; npm install whatsapp-web.js qrcode-terminal
```
```javascript
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
1. Send `msg.body` to any LLM API (DeepSeek, OpenAI, or local Ollama).
2. Add a short system prompt: "You are a helpful assistant for a small business..."
3. Add rate limiting - one reply per user per 5 seconds to avoid spam bans.
4. 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.
Related Articles
2026-06-29
The Mainline Dragon Strategy โ Chasing the Leader Without Paying for Data
2026-06-29
The AI Hiding in Your Laptop
2026-07-14
Free AI Coding Assistant Setup 2026: 5-Min VS Code Guide (Continue, Copilot, Windsurf)
