Skip to main content

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

number
required
Session expiration time in seconds. Default: 300 (5 minutes)
string
required
Keyword to terminate the bot session. Example: “#EXIT”, “bye”
number
required
Delay in milliseconds between messages. Default: 1000
string
required
Message sent when bot encounters an error or cannot respond
boolean
required
Whether bot responds to messages sent by the instance owner
boolean
required
Whether instance owner can stop the bot session
boolean
required
Keep session open after completion. Default: false
number
required
Seconds to wait before processing rapid messages. Default: 10
array
required
List of JIDs (phone numbers) to ignore

Create an N8N Bot

1

Create N8N Workflow

Build your automation workflow in N8N with a Webhook node as the trigger.
2

Get webhook URL

Copy the production webhook URL from your N8N workflow.
3

Configure authentication (optional)

If using Basic Auth in N8N, note your username and password.
4

Create bot in Evolution API

Register the N8N webhook with Evolution API.
5

Test the integration

Send a message matching your trigger to invoke the N8N workflow.

Request Parameters

boolean
required
Enable or disable this bot
string
required
Description of the bot purpose
string
required
N8N webhook URL (production URL from your workflow)
string
Basic authentication username (if webhook is protected)
string
Basic authentication password (if webhook is protected)
string
required
Trigger type: “all”, “keyword”, or “advanced”
string
For keyword triggers: “equals”, “contains”, “startsWith”, “endsWith”, “regex”
string
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

string
The text content of the user’s message
string
Unique session identifier for tracking conversation context
string
WhatsApp JID of the sender
string
Display name of the sender
string
Name of the Evolution API instance
string
Type of message: “conversation”, “imageMessage”, “audioMessage”, etc.
object
Complete WhatsApp message object with metadata

N8N Response Format

Your N8N workflow should return a response in this format:

Message Types

Text Message:
Image Message:
Audio Message:
Document Message:

Trigger Types

All Messages

Respond to every message (only one “all” trigger allowed per instance):

Keyword Trigger

Trigger based on specific keywords:
Available operators:
  • equals - Exact match
  • contains - Contains the keyword
  • startsWith - Message starts with keyword
  • endsWith - Message ends with keyword
  • regex - 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

  1. Webhook trigger receives order message
  2. Parse order details with code node
  3. Create order in database (PostgreSQL/MySQL node)
  4. Send confirmation email (Email node)
  5. Update inventory (HTTP Request node)
  6. Return confirmation message to WhatsApp

CRM Integration

  1. Webhook receives customer message
  2. Search for contact in CRM (Salesforce/HubSpot node)
  3. Create or update contact record
  4. Log interaction in CRM
  5. Check for open tickets
  6. Return personalized response

Support Ticket Creation

  1. Webhook receives support request
  2. Extract issue details with AI (OpenAI node)
  3. Create ticket in system (Jira/Zendesk node)
  4. Assign to team member
  5. Send ticket number to customer
  6. Set up follow-up reminder (Schedule Trigger)

Use Cases

Automate sales processes:
  • Order placement and confirmation
  • Inventory checks and updates
  • Payment processing
  • Shipping notifications
  • Order status tracking
Connect WhatsApp to your CRM:
  • Auto-create/update contacts
  • Log all interactions
  • Trigger sales workflows
  • Update deal stages
  • Sync customer data
Streamline customer support:
  • Auto-create support tickets
  • Route to appropriate teams
  • Update ticket status
  • Send notifications
  • Gather customer feedback
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.
Protect your N8N webhooks with Basic Authentication to prevent unauthorized access.
  • 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

  • Verify N8N_ENABLED=true in 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
  • 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
  • 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
  • Increase expire time if sessions timeout too quickly
  • Set keepOpen: true for longer conversations
  • Use sessionId in N8N workflow for context tracking
  • Store session data in N8N database for persistence

Advanced Configuration

Multiple Workflows

Deploy different workflows for different purposes:

Self-Hosted N8N

For self-hosted N8N installations:
Ensure your N8N instance is accessible from Evolution API server.