{
  "name": "Route measurement data from a webhook to Google Sheets, email, or custom JS",
  "nodes": [
    {
      "id": "7e946a2d-1c05-4b22-8b30-27f97dc0d031",
      "name": "Note - Webhook Entry Point",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -5584,
        -1184
      ],
      "parameters": {
        "width": 400,
        "height": 520,
        "content": "## Webhook Entry Point\n\nReceives POST requests with measurement data at:\n`/measurement-data`\n\n**Expected payload:**\n- measurementId (required)\n- timestamp (required)\n- values (required)\n- deviceId, op"
      }
    },
    {
      "id": "b8839aba-b527-4537-8198-ff6f49383c0d",
      "name": "Note - Validation & Error Handling",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4304,
        -784
      ],
      "parameters": {
        "width": 368,
        "height": 680,
        "content": "##  Validation & Error Handling\n\n**Checks for required fields:**\n- measurementId\n- timestamp\n- values\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n**If validation fails:**\n- Returns 400 error response\n- Stops work"
      }
    },
    {
      "id": "1fea9530-e0fa-48f7-b827-0297ff0171bf",
      "name": "Note - Data Processing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4304,
        -1440
      ],
      "parameters": {
        "width": 560,
        "height": 456,
        "content": "## Data Processing\n\n**Parse and Normalize:**\nExtracts and structures measurement data including dimensions (x, y, z), tolerance, status, and metadata.\n\n**Success Response:**\nReturns 200 OK with confir"
      }
    },
    {
      "id": "004df3a4-4635-4530-90fa-f5b1ee424a2d",
      "name": "Note - Output Routing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3600,
        -1440
      ],
      "parameters": {
        "width": 692,
        "height": 528,
        "content": "## Output Routing\n\nRoutes data based on `outputMode` configuration:\n\n- **sheets** → Google Sheets\n- **html** → HTML Page\n- **csv** → CSV Email\n- **custom** → Custom JavaScript\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Se"
      }
    },
    {
      "id": "073288bb-6bf7-40b3-8b5a-c991b5c7c7b3",
      "name": "Note - Google Sheets Output",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2544,
        -2128
      ],
      "parameters": {
        "width": 488,
        "height": 432,
        "content": "## Google Sheets Output\n\nAppends/updates measurement data to Google Sheets.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n⚠️ **Setup Required:**\n- Configure Google Sheets credentials\n- Set googleSheetId in Workflow Configuration\n"
      }
    },
    {
      "id": "5ef56d94-a716-4231-b184-f370ce1f014c",
      "name": "Note - HTML Output",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2544,
        -1616
      ],
      "parameters": {
        "width": 568,
        "height": 376,
        "content": "## 📄 HTML Report Output\n\nGenerates formatted HTML table with measurement data and returns as web page.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Useful for viewing data directly in browser."
      }
    },
    {
      "id": "2775c854-bd24-4bf7-b89f-82a27c7aeb78",
      "name": "Note - CSV Email Output",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2544,
        -1168
      ],
      "parameters": {
        "width": 536,
        "height": 448,
        "content": "## CSV Email Output\n\nConverts data to CSV file and sends via email.\n\n⚠️ **Setup Required:**\n- Configure SMTP credentials\n- Set emailRecipient in Workflow Configuration\n- Customize emailSubject if need"
      }
    },
    {
      "id": "8ebdc446-9fc6-47ef-ad49-4f4242953872",
      "name": "Note - Custom JavaScript",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2544,
        -672
      ],
      "parameters": {
        "width": 440,
        "height": 500,
        "content": "## Custom JavaScript Logic\n\nExtensible code node with examples for:\n- External API calls\n- S3/cloud storage uploads\n- Triggering other workflows\n- Custom calculations\n- Data transformations\n\n\n\n\n\n\n\n\n\n\n"
      }
    },
    {
      "id": "7784bbae-1604-4945-a230-0a15e4175aa1",
      "name": "Note - Configuration",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -5088,
        -1184
      ],
      "parameters": {
        "width": 416,
        "height": 520,
        "content": "## Workflow Configuration\n\n**Key Settings:**\n- outputMode: 'sheets' | 'html' | 'csv' | 'custom'\n- googleSheetId: Your Google Sheet ID\n- emailRecipient: Email address for CSV\n- emailSubject: Email subj"
      }
    },
    {
      "id": "3334eff6-e5a6-4915-b95a-02258e507822",
      "name": "Validate Required Fields1",
      "type": "n8n-nodes-base.if",
      "position": [
        -4560,
        -864
      ]
    },
    {
      "id": "39ecbe50-5067-4092-a6ed-023ab45ca147",
      "name": "Parse and Normalize Data1",
      "type": "n8n-nodes-base.set",
      "position": [
        -4240,
        -1184
      ]
    },
    {
      "id": "435a73e2-f90a-429d-984c-9db449e664c0",
      "name": "Send Success Response1",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        -3968,
        -1184
      ]
    },
    {
      "id": "77cd0f46-66e8-4175-b2e1-10814a2d48cc",
      "name": "Route to Output Options1",
      "type": "n8n-nodes-base.switch",
      "position": [
        -3168,
        -1232
      ]
    },
    {
      "id": "31c7fa4e-fd95-467c-b6c6-b0280052be2c",
      "name": "Save to Google Sheets1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -2480,
        -2000
      ]
    },
    {
      "id": "40847a27-4468-43c1-b603-670ba2590cc9",
      "name": "Generate HTML Table1",
      "type": "n8n-nodes-base.html",
      "position": [
        -2464,
        -1488
      ]
    },
    {
      "id": "6ebcade9-e215-4656-9fcd-360e1b5515c5",
      "name": "Return HTML Page1",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        -2176,
        -1488
      ]
    },
    {
      "id": "feaa7db6-7908-4fb3-8628-30db47511c5e",
      "name": "Convert to CSV File1",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -2464,
        -896
      ]
    },
    {
      "id": "a0608b0e-34fd-4da6-a8b5-1dbc04421679",
      "name": "Send Email with CSV1",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        -2240,
        -896
      ]
    },
    {
      "id": "44d39600-25f1-4359-914b-a3cf358da708",
      "name": "Custom JavaScript Logic1",
      "type": "n8n-nodes-base.code",
      "position": [
        -2448,
        -416
      ]
    },
    {
      "id": "18cbe32b-9067-4114-b059-f87d4f08dc40",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -6576,
        -1392
      ],
      "parameters": {
        "width": 896,
        "height": 928,
        "content": "# Measurement Data Routing Workflow\n\nThis workflow receives measurement data via webhook and routes it to multiple output destinations based on configuration.\n\n## How it works:\n1. **Webhook receives**"
      }
    },
    {
      "id": "acafb3fd-947c-4782-966e-ee185bffd5e9",
      "name": "Webhook Trigger - Receive Measurement Data",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -5488,
        -864
      ]
    },
    {
      "id": "fe53a33d-c1ad-4bd3-a4b9-a90a7111882e",
      "name": "Send Error Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        -4192,
        -368
      ]
    },
    {
      "id": "4aa05768-a3a3-460f-b5ea-d203bcd8af01",
      "name": "Error - Invalid Payload",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        -4192,
        -576
      ]
    },
    {
      "id": "1930f36c-1b48-4938-8f5e-fe4547023825",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -4976,
        -864
      ]
    }
  ],
  "connections": {
    "Convert to CSV File1": {
      "main": [
        [
          {
            "node": "Send Email with CSV1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate HTML Table1": {
      "main": [
        [
          {
            "node": "Return HTML Page1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Success Response1": {
      "main": [
        [
          {
            "node": "Route to Output Options1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Validate Required Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route to Output Options1": {
      "main": [
        [
          {
            "node": "Save to Google Sheets1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generate HTML Table1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Convert to CSV File1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Custom JavaScript Logic1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse and Normalize Data1": {
      "main": [
        [
          {
            "node": "Send Success Response1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Required Fields1": {
      "main": [
        [
          {
            "node": "Parse and Normalize Data1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error - Invalid Payload",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Error Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook Trigger - Receive Measurement Data": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}