{
  "name": "Nodbot - Tilda to amoCRM lead with UTM and dedupe",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "tilda-form-to-amocrm-lead",
        "responseMode": "responseNode"
      },
      "id": "tilda-form-to-amocrm-lead-01",
      "name": "Webhook input",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -720,
        40
      ]
    },
    {
      "parameters": {
        "jsCode": "const src = $json.body ?? $json;\nconst rawPhone = String(src.phone ?? src.Phone ?? '').trim();\nlet digits = rawPhone.replace(/\\D/g, '');\nif (digits.length === 11 && digits.startsWith('8')) digits = `7${digits.slice(1)}`;\nif (digits.length === 10) digits = `7${digits}`;\nif (!/^7\\d{10}$/.test(digits)) throw new Error(`Invalid phone: ${rawPhone}`);\nconst email = String(src.email ?? '').trim().toLowerCase();\nreturn [{ json: {\n  name: String(src.name ?? src.Name ?? 'Новый лид').trim(),\n  phone_raw: rawPhone,\n  phone_normalized: `+${digits}`,\n  email,\n  comment: String(src.comment ?? src.message ?? '').trim(),\n  utm_source: src.utm_source ?? '',\n  utm_medium: src.utm_medium ?? '',\n  utm_campaign: src.utm_campaign ?? '',\n  utm_content: src.utm_content ?? '',\n  utm_term: src.utm_term ?? '',\n  tilda_form_id: src.formid ?? src.form_id ?? '',\n  dedupe_key: `tilda:${digits}:${email || 'no-email'}`,\n  received_at: new Date().toISOString()\n}}];"
      },
      "id": "tilda-form-to-amocrm-lead-02",
      "name": "Normalize Tilda payload",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -440,
        40
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://YOUR_SUBDOMAIN.amocrm.ru/api/v4/contacts",
        "sendBody": true,
        "contentType": "json",
        "bodyParameters": {
          "parameters": []
        }
      },
      "id": "tilda-form-to-amocrm-lead-03",
      "name": "Find contact or lead in amoCRM",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -160,
        40
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://YOUR_SUBDOMAIN.amocrm.ru/api/v4/leads/complex",
        "sendBody": true,
        "contentType": "json",
        "bodyParameters": {
          "parameters": []
        }
      },
      "id": "tilda-form-to-amocrm-lead-04",
      "name": "Create or update contact+lead",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        120,
        40
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { ok: true, status: \"accepted\" } }}",
        "options": {
          "responseCode": 200
        }
      },
      "id": "tilda-form-to-amocrm-lead-05",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        400,
        40
      ]
    }
  ],
  "connections": {
    "Webhook input": {
      "main": [
        [
          {
            "node": "Normalize Tilda payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Tilda payload": {
      "main": [
        [
          {
            "node": "Find contact or lead in amoCRM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find contact or lead in amoCRM": {
      "main": [
        [
          {
            "node": "Create or update contact+lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create or update contact+lead": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    {
      "name": "nodbot"
    },
    {
      "name": "tilda"
    },
    {
      "name": "amocrm"
    },
    {
      "name": "lead"
    },
    {
      "name": "utm"
    }
  ],
  "triggerCount": 0,
  "updatedAt": "2026-05-30T00:00:00.000Z",
  "versionId": "nodbot-tilda-form-to-amocrm-lead-problem-solution-v1",
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "notes": "Import into n8n, replace amoCRM OAuth credential, subdomain, pipeline_id, status_id and UTM custom field IDs. Dedupe by normalized Russian phone and optional email."
}