{
  "name": "Website contact form to Google Sheet",
  "nodes": [
    {
      "id": "form-webhook",
      "name": "Webhook - website form",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        0
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "website-contact-form",
        "responseMode": "responseNode",
        "options": {
          "allowedOrigins": "https://YOUR-DOMAIN.com,https://www.YOUR-DOMAIN.com",
          "ignoreBots": true
        }
      }
    },
    {
      "id": "form-respond",
      "name": "Instant reply to the site",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        288,
        -128
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "{\n  \"success\": true,\n  \"message\": \"Thanks, we received your details and will get back to you soon.\"\n}",
        "options": {
          "responseCode": 200
        }
      }
    },
    {
      "id": "form-normalize",
      "name": "Normalize form data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        288,
        128
      ],
      "parameters": {
        "jsCode": "// Optional: map the raw value of your \"challenge\" dropdown to a readable label.\nconst CHALLENGE_LABELS = {\n  slowResponse: \"Slow response to new leads\",\n  manualWork: \"Too much time spent on manual tasks\",\n};\n\nconst body = $json.body ?? $json;\n\n// Israeli numbers: keep digits, drop a leading 972 or 0, then add 972.\nfunction normalizePhone(raw) {\n  let digits = String(raw ?? \"\").replace(/\\D/g, \"\");\n  if (digits.startsWith(\"972\")) digits = digits.slice(3);\n  else if (digits.startsWith(\"0\")) digits = digits.slice(1);\n  return digits ? \"972\" + digits : \"\";\n}\n\nconst challengeKey = String(body.challenge ?? \"\");\nconst now = $now.setZone(\"Asia/Jerusalem\");\n\nreturn [\n  {\n    json: {\n      name: String(body.fullName ?? \"\").trim(),\n      phone: normalizePhone(body.phone),\n      email: String(body.email ?? \"\").trim(),\n      company: String(body.businessName ?? \"\").trim(),\n      challenge: CHALLENGE_LABELS[challengeKey] ?? challengeKey,\n      status: \"New\",\n      dateTime: now.toFormat(\"dd/MM/yyyy HH:mm\"),\n    },\n  },\n];"
      }
    },
    {
      "id": "form-sheet",
      "name": "Add or update lead in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        560,
        128
      ],
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_GOOGLE_SHEET_ID"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Leads"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Phone"
          ],
          "value": {
            "Date and time": "={{$json.dateTime}}",
            "Name": "={{$json.name}}",
            "Phone": "={{$json.phone}}",
            "Email": "={{$json.email}}",
            "Business": "={{$json.company}}",
            "Challenge": "={{$json.challenge}}",
            "Status": "={{$json.status}}"
          },
          "schema": [
            {
              "id": "Date and time",
              "displayName": "Date and time",
              "type": "string",
              "required": false,
              "display": true,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Name",
              "displayName": "Name",
              "type": "string",
              "required": false,
              "display": true,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Phone",
              "displayName": "Phone",
              "type": "string",
              "required": false,
              "display": true,
              "defaultMatch": true,
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Email",
              "displayName": "Email",
              "type": "string",
              "required": false,
              "display": true,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Business",
              "displayName": "Business",
              "type": "string",
              "required": false,
              "display": true,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Challenge",
              "displayName": "Challenge",
              "type": "string",
              "required": false,
              "display": true,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Status",
              "displayName": "Status",
              "type": "string",
              "required": false,
              "display": true,
              "defaultMatch": false,
              "canBeUsedToMatch": true,
              "removed": false
            }
          ]
        },
        "options": {}
      }
    }
  ],
  "connections": {
    "Webhook - website form": {
      "main": [
        [
          {
            "node": "Instant reply to the site",
            "type": "main",
            "index": 0
          },
          {
            "node": "Normalize form data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize form data": {
      "main": [
        [
          {
            "node": "Add or update lead in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}
