Skip to main content

Overview

n8n is a powerful, self-hosted workflow automation tool. It’s perfect for teams that need full control over their data and want to run automations on their own infrastructure.
n8n can be self-hosted for complete data privacy or used via n8n Cloud for a managed experience.

Why Use n8n?

Self-Hosted

Run on your own servers with complete data control and no external dependencies.

Open Source

Fully open-source with an active community and extensible architecture.

No Operation Limits

Self-hosted instances have no execution limits — run unlimited workflows.

Code When Needed

Write custom JavaScript/Python code directly in your workflows.

Setting Up Affonso Webhooks in n8n

Step 1: Create a New Workflow

  1. Open your n8n instance
  2. Click Add workflow
  3. Give it a name (e.g., “Affonso Webhook Handler”)

Step 2: Add a Webhook Node

  1. Click + to add a node
  2. Search for Webhook
  3. Configure the webhook:
  1. Copy the Production URL or Test URL
n8n Webhook Node

Step 3: Configure in Affonso

  1. Go to your Affonso dashboard → SettingsWebhooks
  2. Click Add Endpoint
  3. Paste the n8n webhook URL (use Production URL for live workflows)
  4. Select the events you want to receive
  5. Save and activate the endpoint

Step 4: Test the Webhook

  1. In n8n, click Listen for Test Event
  2. Trigger a test event in Affonso
  3. n8n will capture the webhook payload
  4. Review the incoming data structure

Step 5: Build Your Workflow

Add nodes to process the webhook:
  • IF: Branch based on conditions
  • Switch: Route to different paths by event type
  • Code: Custom JavaScript processing
  • HTTP Request: Call external APIs
  • Set: Transform data fields

Example Workflows

Event Router by Type

Route different webhook events to appropriate handlers.

Signature Verification Workflow

Verify Affonso webhook signatures for security.
Signature Verification Code:

Commission Tracking with Database

Store all transactions in PostgreSQL for reporting.
PostgreSQL Insert:

Working with Webhook Data

Accessing Payload Fields

In n8n, access webhook data using expressions:

Data Transformation with Set Node

Transform webhook data for downstream nodes:

Custom Code Processing

Use the Code node for complex logic:

Advanced Patterns

Retry Failed Webhooks

Handle temporary failures with retry logic:

Batch Processing

Collect webhooks and process in batches:

Environment-Based Configuration

Use environment variables for configuration:

Docker Deployment

Self-host n8n with Docker for production use:

Troubleshooting

  • Use the Test URL first, then switch to Production URL
  • Ensure your n8n instance is publicly accessible
  • Check firewall rules allow incoming connections
  • Verify the workflow is Active
  • Click Execute Workflow while listening for test events
  • Check the webhook path matches exactly
  • Review the Executions tab for detailed logs
  • Ensure your server has a valid SSL certificate
  • Use a reverse proxy (nginx/Caddy) for HTTPS
  • Check WEBHOOK_URL environment variable is set correctly
  • Enable execution data pruning in settings
  • Process large payloads in batches
  • Use the Split In Batches node for bulk operations

Best Practices

Use Error Workflow

Set up a global error workflow to catch and notify on failures across all workflows.

Version Control

Export workflows as JSON and store in Git for version control and backup.

Use Sub-Workflows

Break complex logic into reusable sub-workflows for maintainability.

Monitor Resources

Set up monitoring for your n8n instance CPU/memory usage in production.

Resources