Skip to main content

Basic Workflow Example

This example demonstrates a simple webhook trigger that receives data, processes it, and sends a response. This is the foundational pattern for most n8n workflows.

Workflow Overview

The workflow consists of:
  1. Webhook Trigger - Receives incoming HTTP requests
  2. HTTP Request Node - Fetches additional data from an API
  3. Set Node - Transforms and structures the data
  4. Respond to Webhook - Returns the processed result

Use Cases

  • API endpoint creation
  • Data transformation pipelines
  • Simple automation triggers
  • Testing and development workflows

Complete Workflow JSON

{
  "name": "Basic Webhook to API",
  "nodes": [
    {
      "id": "webhook-1",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [250, 300],
      "parameters": {
        "httpMethod": "POST",
        "path": "process-data",
        "responseMode": "lastNode",
        "options": {}
      },
      "webhookId": "basic-webhook"
    },
    {
      "id": "http-1",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [450, 300],
      "parameters": {
        "method": "GET",
        "url": "https://api.github.com/repos/{{$json.owner}}/{{$json.repo}}",
        "authentication": "none",
        "options": {
          "timeout": 10000
        }
      }
    },
    {
      "id": "set-1",
      "name": "Format Response",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [650, 300],
      "parameters": {
        "mode": "manual",
        "assignments": {
          "assignments": [
            {
              "id": "assign-1",
              "name": "repository",
              "value": "={{$json.name}}",
              "type": "string"
            },
            {
              "id": "assign-2",
              "name": "stars",
              "value": "={{$json.stargazers_count}}",
              "type": "number"
            },
            {
              "id": "assign-3",
              "name": "description",
              "value": "={{$json.description}}",
              "type": "string"
            },
            {
              "id": "assign-4",
              "name": "url",
              "value": "={{$json.html_url}}",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "respond-1",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [850, 300],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{$json}}",
        "options": {}
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Format Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Response": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "active": false
}

Step-by-Step Breakdown

1

Webhook Trigger Setup

The webhook node listens for POST requests on the /process-data path. It expects JSON data with owner and repo fields.Key Parameters:
  • httpMethod: POST (accepts data in request body)
  • path: Custom endpoint path
  • responseMode: lastNode (returns data from final node)
2

Fetch Repository Data

The HTTP Request node uses the incoming data to fetch repository information from GitHub’s API.Key Features:
  • Uses n8n expressions: {{$json.owner}} and {{$json.repo}}
  • No authentication required for public repos
  • 10-second timeout for reliability
3

Transform Response

The Set node extracts specific fields and formats the response data.Transformations:
  • Extracts repository name, stars, description, and URL
  • Uses type conversion (string, number)
  • Creates clean, predictable output structure
4

Return to Client

The Respond to Webhook node sends the processed data back to the original HTTP request.Response Format: JSON object with formatted repository information

Expected Response

{
  "repository": "n8n",
  "stars": 45238,
  "description": "Fair-code workflow automation platform",
  "url": "https://github.com/n8n-io/n8n"
}
Best Practice: Always validate your workflow with validate_workflow() before deployment to catch configuration errors early.

Common Modifications

Add Authentication

Update the HTTP Request node to include authentication:
{
  "parameters": {
    "authentication": "genericCredentialType",
    "genericAuthType": "httpHeaderAuth"
  }
}

Add Error Handling

Set continueOnFail: true on the HTTP Request node to prevent workflow failures.

Rate Limiting

Add a Wait node between requests to respect API rate limits.

Next Steps

Build docs developers (and LLMs) love