A production-ready WhatsApp automation framework featuring Anti-Ban protection, n8n integration, and RAG support.
Note: This is the open-source community edition of the internal framework used by GX Automation Tech. For enterprise-grade, fully compliant WhatsApp solutions (Green Tick verification), please contact us for our official respond.io implementation services.
This project uses the unofficial WhatsApp Web API (@whiskeysockets/baileys).
- Ban Risk: Using this library creates a risk of your WhatsApp phone number being permanently banned.
- Anti-Ban Logic: While this project includes sophisticated "human-like" behavior simulation (variable typing delays, rate limiting, sleep cycles), no protection is 100% foolproof.
- Liability: The authors are not responsible for any banned numbers, lost data, or business interruption resulting from the use of this software.
- Recommendation: For business-critical numbers, use the official WhatsApp Business API (or our managed service).
- 🛡️ Advanced Anti-Ban System:
- Variable Delays: Calculates "human reading time" + "typing time" before replying.
- Typing Simulation: Shows "Typing..." status to the user during the delay.
- Rate Limiting: configurable limits (e.g., max 50 msgs/hour) with visual health bars.
- Time-of-Day Logic: Slower response times at night to mimic human sleep cycles.
- 🧠 n8n Integration:
- Offload all logic to n8n (Visual Workflow Editor).
- Supports OpenAI, Google Gemini, Anthropic, or Local LLMs via n8n.
- Supports RAG (Retrieval Augmented Generation) for Knowledge Base lookups.
- 🔌 Plug-and-Play Architecture: Built on Node.js + Express.
- 📊 Web Admin Panel:
- Scan QR Codes directly in the browser.
- Real-time connection status.
- Live Activity Logs.
- Dynamic Configuration (Update Webhook URLs without restarting).
- 🌍 Multi-Language Support: Ready for English, Bahasa Malaysia, and Mandarin.
Before you begin, ensure you have:
- Node.js (v18 or higher): Download Here
- n8n Instance:
- Cloud: Sign up for n8n Cloud (Easiest)
- Self-Hosted:
npm install n8n -g(Free)
- A WhatsApp Number: We recommend using a secondary number for testing first.
-
Clone the repository:
git clone https://github.com/yourusername/whatsapp-ai-framework.git cd whatsapp-ai-framework -
Install dependencies:
cd app npm install -
Start the Server:
npm start
You will see a message:
🌐 Web UI: http://localhost:3000
This bot needs a "brain" to decide what to say. We use n8n for this.
- Open n8n: Go to your n8n dashboard.
- Import Workflow:
- Click Add Workflow > Import from File.
- Select
n8n-workflows/advanced-chat-gemini.jsonfrom this project folder.
- Configure Credentials:
- Double-click the Google Gemini node (or OpenAI node).
- Select "Create New Credential" and paste your API Key.
- Activate the Webhook:
- Double-click the Webhook node.
- Ensure "HTTP Method" is
POST. - IMPORTANT: If you are running the bot locally and n8n in the cloud, n8n gives you a URL like
https://your-n8n.cloud/webhook/whatsapp-webhook. Copy this URL. - Note: If running n8n locally, use a tunnel like
ngrokortunnelmoleto make it accessible.
- Save & Activate: Click Save and toggle Active to true.
- Open the Bot Admin Panel at
http://localhost:3000. - Scroll down to the AI Configuration card.
- Paste your n8n Webhook URL (from Step 2) into the input field.
- Click Save Webhook URL.
- This saves the URL to
settings.json, so it persists even if you restart.
- This saves the URL to
- In the Admin Panel, look at the Connection Info card.
- Click the green Connect button.
- Wait a moment for the QR Code to appear.
- Open WhatsApp on your phone:
- iOS: Settings > Linked Devices > Link a Device.
- Android: Three dots > Linked Devices > Link a Device.
- Scan the QR code.
- The status should change to Connected (Green).
🎉 Your bot is now live! Send a message to your WhatsApp number from a different phone to test it.
The bot comes with pre-configured "Human Behavior" profiles. You can change these in the Anti-Ban Settings card.
| Preset | Messages/Hour | Description |
|---|---|---|
| New Account | 30 | Strict limits. Use this for numbers < 1 month old. |
| Balanced | 50 | Recommended default. Good balance of speed and safety. |
| Higher | 80 | For established business numbers (> 6 months old). |
| Custom | ??? | Define your own limits. |
How it works:
- Limit Reached: If the bot hits the hourly limit (e.g., 51st message), it will stop replying until the next hour to protect your number. The user logs will show "Rate Limited".
- Health Bars: Watch the "Current Usage" bars in the dashboard.
- Green: Safe zone.
- Yellow: Caution.
- Red: Limit reached.
To automatically backup your chat logs to Google Drive:
- Place your
google-credentials.json(Service Account Key) in theapp/folder. - Add
GOOGLE_DRIVE_FOLDER_ID=your_folder_idto your.envfile. - The bot will now sync logs to the cloud every 30 days or when you click "Backup" manually.
Q: The QR code isn't loading. A: Click "Disconnect", wait 5 seconds, and click "Connect" again. If that fails, click "Clear Auth" to reset the session.
Q: The bot isn't replying. A:
- Check the Activity Log in the dashboard. Does it say "Sending to n8n..."?
- If yes, check your n8n Executions tab. Did the workflow run?
- If no, check if your n8n Webhook URL is correct in the Admin Panel.
Q: The reply is too slow.
A: This is a feature, not a bug! The bot calculates how long a human would take to read the message and type a reply. You can adjust the math in app/src/utils/anti-ban.js if you want it faster (but it increases ban risk).
MIT License. Free to use and modify.