N8N Integration
N8N is a powerful open-source workflow automation platform that connects various apps and services. You can integrate N8N with Evolution API to create sophisticated WhatsApp automation workflows.What is N8N?
N8N provides:- Visual workflow builder with 400+ integrations
- Custom code execution (JavaScript/Python)
- Webhook triggers and actions
- Database connectors
- API integrations
- Conditional logic and branching
- Error handling and retry logic
- Scheduled workflows
Enable N8N Integration
Add this environment variable to your.env file:
Configuration Settings
Create Default Settings
Before creating N8N bots, configure default behavior settings for your instance.Settings Parameters
Session expiration time in seconds. Default: 300 (5 minutes)
Keyword to terminate the bot session. Example: “#EXIT”, “bye”
Delay in milliseconds between messages. Default: 1000
Message sent when bot encounters an error or cannot respond
Whether bot responds to messages sent by the instance owner
Whether instance owner can stop the bot session
Keep session open after completion. Default: false
Seconds to wait before processing rapid messages. Default: 10
List of JIDs (phone numbers) to ignore
Create an N8N Bot
Request Parameters
Enable or disable this bot
Description of the bot purpose
N8N webhook URL (production URL from your workflow)
Basic authentication username (if webhook is protected)
Basic authentication password (if webhook is protected)
Trigger type: “all”, “keyword”, or “advanced”
For keyword triggers: “equals”, “contains”, “startsWith”, “endsWith”, “regex”
The keyword or regex pattern to trigger this bot
Webhook Payload
When a trigger is matched, Evolution API sends this payload to your N8N webhook:Payload Fields
The text content of the user’s message
Unique session identifier for tracking conversation context
WhatsApp JID of the sender
Display name of the sender
Name of the Evolution API instance
Type of message: “conversation”, “imageMessage”, “audioMessage”, etc.
Complete WhatsApp message object with metadata
N8N Response Format
Your N8N workflow should return a response in this format:Message Types
Text Message:Trigger Types
All Messages
Respond to every message (only one “all” trigger allowed per instance):Keyword Trigger
Trigger based on specific keywords:equals- Exact matchcontains- Contains the keywordstartsWith- Message starts with keywordendsWith- Message ends with keywordregex- Regular expression match
Advanced Trigger
Use regex for complex pattern matching:Update N8N Bot
Modify an existing N8N bot configuration:Delete N8N Bot
Remove an N8N bot from your instance:Fetch N8N Bots
Retrieve all N8N bots configured for your instance:Session Management
Change Session Status
Update the status of an active N8N session:Fetch Sessions
Get all active N8N sessions:N8N Workflow Examples
Order Processing
- Webhook trigger receives order message
- Parse order details with code node
- Create order in database (PostgreSQL/MySQL node)
- Send confirmation email (Email node)
- Update inventory (HTTP Request node)
- Return confirmation message to WhatsApp
CRM Integration
- Webhook receives customer message
- Search for contact in CRM (Salesforce/HubSpot node)
- Create or update contact record
- Log interaction in CRM
- Check for open tickets
- Return personalized response
Support Ticket Creation
- Webhook receives support request
- Extract issue details with AI (OpenAI node)
- Create ticket in system (Jira/Zendesk node)
- Assign to team member
- Send ticket number to customer
- Set up follow-up reminder (Schedule Trigger)
Use Cases
E-commerce Automation
E-commerce Automation
Automate sales processes:
- Order placement and confirmation
- Inventory checks and updates
- Payment processing
- Shipping notifications
- Order status tracking
CRM Integration
CRM Integration
Connect WhatsApp to your CRM:
- Auto-create/update contacts
- Log all interactions
- Trigger sales workflows
- Update deal stages
- Sync customer data
Support Ticketing
Support Ticketing
Streamline customer support:
- Auto-create support tickets
- Route to appropriate teams
- Update ticket status
- Send notifications
- Gather customer feedback
Multi-System Orchestration
Multi-System Orchestration
Connect multiple platforms:
- Database operations
- API integrations
- File processing
- Data transformation
- Cross-system synchronization
Best Practices
Always activate your N8N workflows before testing with Evolution API. Use production webhook URLs, not test URLs.
- Use error handling: Add error catch nodes in N8N workflows
- Validate inputs: Check and sanitize data from WhatsApp messages
- Implement timeouts: Set reasonable timeout values for external API calls
- Log executions: Enable execution logging in N8N for debugging
- Test workflows: Thoroughly test in N8N before connecting to WhatsApp
- Secure webhooks: Always use HTTPS and authentication
- Handle async operations: Use webhooks or callbacks for long-running tasks
Troubleshooting
Workflow not triggered
Workflow not triggered
- Verify
N8N_ENABLED=truein environment - Check that bot is enabled (
enabled: true) - Ensure trigger conditions match incoming messages
- Verify N8N workflow is activated (not in draft)
- Check webhook URL is correct and accessible
- Test webhook manually with curl or Postman
Authentication errors
Authentication errors
- Verify Basic Auth credentials are correct
- Check that credentials match N8N webhook settings
- Ensure webhook has authentication enabled if using credentials
- Test authentication with curl
No response from workflow
No response from workflow
- Check N8N execution logs for errors
- Verify workflow returns proper response format
- Ensure all nodes execute successfully
- Check for timeout issues in long-running workflows
- Verify network connectivity between Evolution API and N8N
Session not maintained
Session not maintained
- Increase
expiretime if sessions timeout too quickly - Set
keepOpen: truefor longer conversations - Use sessionId in N8N workflow for context tracking
- Store session data in N8N database for persistence