{
  "name": "Web Form Submission to Google Sheets",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "form-submission",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "sfms0001-0001-4000-8000-000000000001",
      "name": "Form Submission Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300]
    },
    {
      "parameters": {
        "conditions": {
          "conditions": [
            {
              "leftValue": "={{ $json.body.email }}",
              "rightValue": "",
              "operator": { "type": "string", "operation": "notEmpty" }
            }
          ]
        }
      },
      "id": "sfms0001-0002-4000-8000-000000000002",
      "name": "Email Provided?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            { "id": "f1", "name": "name", "value": "={{ $json.body.name || '' }}", "type": "string" },
            { "id": "f2", "name": "email", "value": "={{ $json.body.email.toLowerCase().trim() }}", "type": "string" },
            { "id": "f3", "name": "message", "value": "={{ $json.body.message || '' }}", "type": "string" },
            { "id": "f4", "name": "source", "value": "={{ $json.body.source || 'website' }}", "type": "string" },
            { "id": "f5", "name": "submitted_at", "value": "={{ $now.toISO() }}", "type": "string" }
          ]
        },
        "options": {}
      },
      "id": "sfms0001-0003-4000-8000-000000000003",
      "name": "Prepare Row Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [680, 220]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": { "__rl": true, "mode": "id", "value": "={{ $env.FORM_SHEET_ID }}" },
        "sheetName": { "__rl": true, "mode": "name", "value": "Submissions" },
        "columns": {
          "mappingMode": "autoMapInputData",
          "options": {}
        },
        "options": {}
      },
      "id": "sfms0001-0004-4000-8000-000000000004",
      "name": "Append to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [900, 220]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={ \"ok\": true, \"message\": \"Submission received\" }",
        "options": {}
      },
      "id": "sfms0001-0005-4000-8000-000000000005",
      "name": "Respond OK",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [1120, 220]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={ \"ok\": false, \"message\": \"Email is required\" }",
        "options": { "responseCode": 400 }
      },
      "id": "sfms0001-0006-4000-8000-000000000006",
      "name": "Respond Error",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [680, 400]
    }
  ],
  "connections": {
    "Form Submission Webhook": {
      "main": [[{ "node": "Email Provided?", "type": "main", "index": 0 }]]
    },
    "Email Provided?": {
      "main": [
        [{ "node": "Prepare Row Data", "type": "main", "index": 0 }],
        [{ "node": "Respond Error", "type": "main", "index": 0 }]
      ]
    },
    "Prepare Row Data": {
      "main": [[{ "node": "Append to Google Sheets", "type": "main", "index": 0 }]]
    },
    "Append to Google Sheets": {
      "main": [[{ "node": "Respond OK", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
