Your business gets WhatsApp messages at 3am. Nobody answers. Lead lost.
I built a bot that handles this automatically — qualifies leads, answers questions, and sends payment links. Here is the architecture.
The Stack
Baileys (WhatsApp Web protocol, no Meta API needed)
Claude API for intelligent responses
SQLite for CRM (contacts, lead scores, conversation history)- Zero external dependencies. Runs on a $5 VPS.
How It Works
// Message comes in
sock.ev.on("messages.upsert", async ({ messages }) => {
const msg = messages[0];
const text = msg.message?.conversation || "";
const from = msg.key.remoteJid;
// Track in CRM
crm.trackContact(from, text);
// AI generates response with context
const history = crm.getHistory(from, 20);
const response = await claude.chat({
system: salesPrompt,
messages: history
});
// Send reply
await sock.sendMessage(from, { text: response });
// Auto-detect buying intent
if (response.includes("payment")) {
crm.updateStage(from, "closing");
}
});
Built-in CRM
Every contact gets:
Lead score (0-100) based on buying signals
Sales stage: new → interested → qualified → closing → converted
Tags: auto-applied (lead, hot-lead, customer)
Full conversation history for AI context
CREATE TABLE contacts (
phone TEXT PRIMARY KEY,
name TEXT,
lead_score INTEGER DEFAULT 0,
stage TEXT DEFAULT "new",
tags TEXT DEFAULT "",
messages_count INTEGER DEFAULT 0,
first_seen INTEGER,
last_seen INTEGER
);
Sales Automation
The AI handles the full funnel:
Greeting — warm, asks about needs
Qualification — understands budget/timeline
Objection handling — addresses concerns naturally
Closing — sends payment link at the right moment
Follow-up — checks in after 24h silence
Not pushy. Not robotic. It builds genuine trust.
Deploy in 5 Minutes
npm install
cp .env.example .env # add your Claude API key
npm start # scan QR code, done
Or Docker:
docker compose up -d
Get the Full Template
14 files, 1450 lines of production code. CRM, sales automation, multi-language, Docker deployment.
WhatsApp AI Bot Template — $79.99
Also available:
What channels are you automating with AI?
SOCIAL SHARE CARD GENERATOR