This Node.js project utilizes the Baileys library to monitor messages from a specific user within a group and forward them automatically to an automation workflow in n8n.
This version is optimized for server environments (VPS) and Docker containers, fixing common connection failures and ensuring session persistence.
- Auto-Version Patch: Automatically detects the latest WhatsApp Web version to prevent the
405 Method Not Allowederror. - Browser Spoofing: Updated browser headers to reduce the risk of IP banning in Data Centers.
- Robust Persistence: Engineered for Docker volumes, eliminating the need for frequent QR Code rescanning.
- Connects to WhatsApp Web using Baileys with multi-file authentication.
- Generates a QR Code in the terminal for first-time authentication.
- Monitors messages from a specific user in a specific group.
- Sends messages to an n8n webhook for automation workflows.
- Includes routes:
- list-groups.js → Lists all WhatsApp groups the account participates in.
- index-geral.js → General entry point for custom workflows.
- index.js → Main entry point to run the bot fully.
- Fully configurable via .env.
.
├── auth/ # Stores session keys (Generated automatically)
├── .env # Configuration variables (NEVER commit to Git)
├── .gitignore # Sensitive file protection
├── Dockerfile # Instructions for Easypanel/Docker builds
├── index.js # Main bot with filtering and webhook logic
├── list-groups.js # Utility to discover Group IDs (JID)
├── package.json # Project dependencies
└── README.md # Documentation
- Node.js >= 18
- npm
- WhatsApp account
- n8n webhook URL
- Internet connection
-
Clone the repository: git clone https://github.com/cauerast/BotWhatsapp.git
cd BotWhatsapp -
Install dependencies:
npm install -
Create a .env file:
N8N_WEBHOOK=https://github.com/cauerast/BotWhatsapp
GROUP_ID=123456789101112131415161718@g.us
TARGET_NUMBER=5599999999999@s.whatsapp.net
-
Run the main bot:
node index.js- Generates QR Code
- Connects to WhatsApp
- Monitors group and forwards messages to n8n
-
List all WhatsApp groups:
node list-groups.jsUse this to find your GROUP_ID.
-
General workflow route:
node index-geral.js
N8N_WEBHOOK → Your n8n webhook URL
GROUP_ID → WhatsApp group ID to monitor
TARGET_NUMBER → Specific WhatsApp number to filter messages
----------SCAN THE QR CODE BELOW----------
(qrcode)
----------Connected to WhatsApp!----------
Message filtered: Hello World!
Sent to n8n successfully!
MIT License
Cauê Silva Rasteiro
GitHub: https://github.com/cauerast
LinkedIn: https://www.linkedin.com/in/cauê-rast-26bba22a6/