MANUAL
WhatsApp Baileys
Introduction
What is WhatsApp Baileys?
Baileys is an unofficial open-source library that connects to WhatsApp Web from Node.js. It is completely FREE and requires no business account or verification.
Architecture
+----------------+ +-----------------+ +----------------+ +----------------+
| User | --> | WhatsApp Web | --> | Sidecar WA | --> | Fararoni |
| WhatsApp | | (Baileys) | | (:3000) | | Gateway |
+----------------+ +-----------------+ +----------------+ | (:7071) |
+----------------+
|
v
+----------------+
| LLM Agents |
+----------------+Advantages
| Feature | Value |
|---|---|
| Cost | FREE |
| Requires business account | NO |
| Setup | 15 minutes |
| Ideal for | Development, testing, personal use |
Limitations (Warning)
| Limitation | Description |
|---|---|
| Ban risk | Meta can block your number if it detects automation |
| Unofficial API | Baileys may stop working if Meta changes something |
| No support | No official Meta support |
| One device | Can only be linked to one device at a time |
IMPORTANT: For enterprise production, use WhatsApp Enterprise.
When to use Baileys?
- Local development and testing
- Personal projects
- POCs (Proof of Concept)
- When you can't afford WhatsApp Enterprise
- Moderate use bots (no spam)
Prerequisites
Required Software
- Node.js 20 or higher
- npm (comes with Node.js)
- Fararoni Core installed
- Java 25+ with --enable-preview
- Phone with WhatsApp installed and working
- Active phone number on WhatsApp
- Phone must have internet connection
Ports
| Port | Service | Required State |
|---|---|---|
| 7071 | Gateway REST | Open (local) |
| 3000 | Sidecar WhatsApp | Open (local) |
# Verify Node.js (must be 20+)
node --version
# Verify npm
npm --version
# Verify Java
java --versionChannel Encryption
| Scenario | Key env var | DEV_MODE | Result |
|---|---|---|---|
| Production with key | "abc123..." | false | Uses env key |
| Production without key | (empty) | false | LOG.severe warns |
| Development without key | (empty) | true | Auto-generates persistent AES-256 key |
# Local development
export FARARONI_DEV_MODE=true
# Key is auto-generatedInstall the Sidecar
cd /path/to/fararoni/fararoni-sidecar-wa
npm installThis will install: @whiskeysockets/baileys, express, axios, qrcode-terminal
Configure Fararoni
Verify modules.yml
Location: ~/.fararoni/config/modules.yml
channels:
whatsapp:
enabled: true
trust_level: UNTRUSTED_EXTERNAL
egress_url: "http://localhost:3000/send"
capabilities:
- text
- audio
- image
timeout_ms: 5000
retry_count: 3REST Gateway
gateway:
rest:
enabled: true
port: 7071Getting Started
Start Order (IMPORTANT)
1. Fararoni Core (Gateway) <-- FIRST
2. Sidecar WhatsApp <-- SECONDTerminal 1: Start Fararoni Core
cd /path/to/fararoni/fararoni-core/target
java --enable-preview -jar fararoni-core-1.0.0.jar --serverWait until you see:
[MODULE-REGISTRY] Loaded module: OmniChannelGatewayModule
[INGRESS] RestIngressServer listening on port 7071Terminal 2: Start WhatsApp Sidecar
cd /path/to/fararoni/fararoni-sidecar-wa
npm startThe first time, you'll see a QR code in the terminal.
Scan QR Code
See QR in Terminal
█████████████████████████████████████
█████████████████████████████████████
████ ▄▄▄▄▄ █▀█ █▄ ▀▄█▀▄█ ▄▄▄▄▄ ████
...
[INFO] Scan the QR code with your WhatsAppOpen WhatsApp on Phone
- Open WhatsApp on your phone
- Tap the three dots (menu) in the top right corner
- Select "Linked Devices"
- Tap "Link a Device"
- Point the camera at the QR in the terminal
Verify Successful Connection
[INFO] Connection established
[INFO] Session saved in ./baileys_auth_info/
[INFO] WhatsApp connected. Ready to receive messages.Session is Saved
The session is saved in fararoni-sidecar-wa/baileys_auth_info/. Next time you won't need to scan again.
When Does the Session Expire?
| Cause | Description |
|---|---|
| Prolonged inactivity | WhatsApp closes the session after several days |
| Manual close | If you close from "Linked Devices" |
| New device | If you link another and exceed the limit |
| WhatsApp update | May invalidate sessions |
| Network change | Drastic IP changes |
How to Re-authenticate
cd fararoni-sidecar-wa && rm -rf baileys_auth_info && npm startDeleting baileys_auth_info/ forces a clean authentication from scratch, as the local credentials become desynchronized with WhatsApp's server.
Verify Operation
Gateway Health Check
curl http://localhost:7071/gateway/v1/health
# {"status": "healthy", "module": "gateway-rest-omnichannel"}Sidecar Health Check
curl http://localhost:3000/health
# {"status": "connected", "phone": "+522291234567"}End-to-End Test
- From another phone, send a message to your WhatsApp number
- You should receive an automatic response from Fararoni
Verify Logs
[INGRESS] +522299876543 -> "Hello, I need help"
[EGRESS] +522299876543 <- "Hello! I'm Fararoni, how can I help you?"Security
Group Filter
By default, the sidecar ONLY responds to private chats (1:1).
| Chat Type | Processed? |
|---|---|
| Private chat (1:1) | YES |
| Group | NO |
| Broadcast list | NO |
How the Filter Works
if (remoteJid.endsWith('@g.us')) {
console.log('[FILTER] Ignoring group message:', remoteJid);
return;
}Enable Specific Groups
const ALLOWED_GROUPS = [
'123456789-1234567890@g.us',
'987654321-0987654321@g.us'
];
if (remoteJid.endsWith('@g.us') && !ALLOWED_GROUPS.includes(remoteJid)) {
return;
}Ban Risk
| Practice | Risk |
|---|---|
| Responding to incoming messages | Low |
| Sending mass messages (spam) | VERY HIGH |
| Very fast responses (< 1 second) | Medium |
| Moderate use (< 100 messages/day) | Low |
| Intensive use (> 500 messages/day) | High |
Recommendations: Use Baileys only for development and testing. For production, consider WhatsApp Enterprise. Don't spam.
Troubleshooting
QR doesn't appear
rm -rf baileys_auth_info
npm startError "Session closed" or "Connection Failure"
Cause: WhatsApp session expired or was invalidated.
cd fararoni-sidecar-wa && rm -rf baileys_auth_info && npm startThen scan the new QR.
Error "ECONNREFUSED"
Cause: Gateway not running.
java --enable-preview -jar fararoni-core-1.0.0.jar --serverBot doesn't respond
# Verify Gateway
curl http://localhost:7071/gateway/v1/health
# Verify Sidecar
curl http://localhost:3000/healthIf health says "disconnected", delete the session and scan QR again.
Error "Number banned"
- Wait 24-72 hours and retry
- Appeal the ban from WhatsApp
- Use another number
- Consider WhatsApp Enterprise (no ban risk)
Useful Commands
# Gateway health
curl http://localhost:7071/gateway/v1/health
# Sidecar health
curl http://localhost:3000/health
# View current QR
curl http://localhost:3000/qr
# Reset session
cd fararoni-sidecar-wa
rm -rf baileys_auth_info
npm start
# Stop services
pkill -f "fararoni-core"
pkill -f "fararoni-sidecar-wa"Environment Variables
| Variable | Default | Description |
|---|---|---|
SIDECAR_PORT | 3000 | HTTP server port |
GATEWAY_URL | http://localhost:7071/gateway/v1/inbound | Gateway URL |
AUTH_DIR | ./baileys_auth_info | Session directory |
LOG_LEVEL | info | Log level |
Appendices
Implementation Checklist
REQUIREMENTS
[ ] Node.js 20+ installed
[ ] Fararoni Core installed
[ ] Java 25+ with --enable-preview
[ ] Phone with WhatsApp
INSTALLATION
[ ] npm install executed
[ ] modules.yml has whatsapp.enabled: true
GETTING STARTED
[ ] Gateway running on port 7071
[ ] Sidecar running on port 3000
[ ] QR code visible in terminal
LINKING
[ ] QR scanned from WhatsApp
[ ] Session saved in baileys_auth_info/
TESTING
[ ] Health checks OK
[ ] Message sent from another phone
[ ] Response receivedDifferences with Enterprise
| Aspect | Baileys | Enterprise |
|---|---|---|
| Cost | Free | Pay per message |
| Ban risk | Yes | No |
| API | Unofficial | Official (Meta) |
| Setup | 15 min | 2-5 days |
| Support | Community | Meta official |
| Templates | No | Yes |
| Mass messaging | Not recommended | Yes |
| Ideal for | Development | Production |
Author: Fararoni Team | Version: 1.0