Package Information
Documentation
N8N WhatsApp Automation Nodes
This package provides N8N nodes for WhatsApp automation using a WhatsApp server API.
Features
- WhatsApp Connect Node: Connect to WhatsApp using QR code (data or image)
- WhatsApp Trigger Node: Listen for incoming messages and connection events
- Credential Management: Secure storage of WhatsApp server connection details
Installation
Option 1: Install from NPM (Recommended)
npm install n8n-whats-auto
Then restart your N8N instance to load the new nodes.
Option 2: Install from Source
- Clone and build the nodes:
git clone https://github.com/yourusername/n8n-whats-auto.git
cd n8n-whats-auto
npm install
npm run build
- Link the nodes to your N8N installation:
npm link
cd ~/.n8n/nodes
npm link n8n-whats-auto
- Restart N8N to load the new nodes.
Configuration
WhatsApp Server API Credentials
Before using the nodes, you need to set up WhatsApp Server API credentials:
- Go to N8N Credentials
- Create new "WhatsApp Server API" credential
- Configure:
- Server URL: Your WhatsApp server URL (e.g.,
http://localhost:8000) - API Key: Optional API key for authentication
- Session ID: Unique identifier for your WhatsApp session
- Server URL: Your WhatsApp server URL (e.g.,
Nodes
WhatsApp Connect Node
Connects to WhatsApp and manages sessions.
Operations:
- Connect with QR Data: Get raw QR code data for custom QR generation
- Connect with QR Image: Get QR code as base64 image
- Check Session Status: Check if session is connected and authenticated
- Delete Session: Remove a WhatsApp session
Parameters:
- Use Legacy Mode: Enable legacy WhatsApp mode (boolean)
Output:
{
"success": true,
"message": "QR code data received, please scan the QR code.",
"data": {
"qr": "2@ABC123...",
"sessionId": "your-session-id"
}
}
WhatsApp Trigger Node
Listens for WhatsApp messages and events.
Trigger Options:
- All Messages: Trigger on all incoming messages
- Text Messages Only: Only text messages
- Media Messages Only: Only media messages (images, videos, etc.)
- Group Messages: Only group messages
- Direct Messages: Only direct messages
- Connection Events: Connection status changes
Parameters:
- Polling Interval: How often to check for messages (1-300 seconds)
- Filter Keywords: Comma-separated keywords to filter messages
Output for Messages:
{
"type": "message",
"messageId": "message-id",
"sessionId": "your-session-id",
"chatId": "chat-id",
"isGroup": false,
"sender": "sender-id",
"timestamp": 1234567890,
"messageText": "Hello world",
"hasMedia": false,
"chat": {
"id": "chat-id",
"name": "Chat Name",
"isGroup": false
}
}
Output for Connection Events:
{
"type": "connection_event",
"event": "connected",
"sessionId": "your-session-id",
"timestamp": "2024-01-01T00:00:00.000Z",
"status": "authenticated",
"userInfo": {
"id": "user-id",
"name": "User Name"
}
}
Usage Examples
Basic Setup Workflow
Connect to WhatsApp:
- Add WhatsApp Connect node
- Select "Connect with QR Data" operation
- Execute to get QR code data
- Scan QR code with WhatsApp mobile app
Listen for Messages:
- Add WhatsApp Trigger node
- Select trigger type (e.g., "All Messages")
- Set polling interval (e.g., 5 seconds)
- Connect to other nodes for message processing
Advanced Message Filtering
{
"triggerOn": "textMessages",
"filterKeywords": "help,support,question",
"pollingInterval": 3
}
This will trigger only on text messages containing "help", "support", or "question".
API Endpoints Used
The nodes interact with these WhatsApp server endpoints:
POST /sessions/add-qr-data- Get QR code dataPOST /sessions/add- Get QR code imageGET /sessions/status/{sessionId}- Check session statusDELETE /sessions/delete/{sessionId}- Delete sessionGET /chats?id={sessionId}- Get chat listGET /chats/{chatId}/messages?id={sessionId}- Get messages
Troubleshooting
Common Issues
"Session not found" error:
- Ensure your session ID is correct in credentials
- Check if the session was created successfully
"Connection timeout" error:
- Verify your WhatsApp server is running
- Check the server URL in credentials
No messages received:
- Verify the session is authenticated
- Check polling interval settings
- Ensure message filters are not too restrictive
Debug Mode
Enable debug logging in N8N to see detailed API requests and responses.
Development
Building
npm run build
Development Mode
npm run dev
Linting
npm run lint
npm run lintfix
License
MIT License
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Support
For issues and questions:
- Check the troubleshooting section
- Review WhatsApp server logs
- Open an issue on GitHub