{
  "name": "Nodbot - Tilda to Bitrix24 lead without duplicates",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "tilda-form-to-bitrix24-lead",
        "responseMode": "responseNode"
      },
      "id": "tilda-form-to-bitrix24-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}}];\n// Bitrix24 expects fields like TITLE, NAME, PHONE, EMAIL and UTM_*.\nreturn items.map(item => ({ json: {\n  fields: {\n    TITLE: `Заявка Tilda: ${item.json.name}`,\n    NAME: item.json.name,\n    PHONE: [{ VALUE: item.json.phone_normalized, VALUE_TYPE: 'WORK' }],\n    EMAIL: item.json.email ? [{ VALUE: item.json.email, VALUE_TYPE: 'WORK' }] : [],\n    COMMENTS: item.json.comment,\n    UTM_SOURCE: item.json.utm_source,\n    UTM_MEDIUM: item.json.utm_medium,\n    UTM_CAMPAIGN: item.json.utm_campaign,\n    UTM_CONTENT: item.json.utm_content,\n    UTM_TERM: item.json.utm_term\n  },\n  dedupe_key: item.json.dedupe_key\n}}));"
      },
      "id": "tilda-form-to-bitrix24-lead-02",
      "name": "Normalize and map Bitrix24 fields",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -440,
        40
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://YOUR_PORTAL.bitrix24.ru/rest/CRM_WEBHOOK/crm.duplicate.findbycomm.json",
        "sendBody": true,
        "contentType": "json",
        "bodyParameters": {
          "parameters": []
        }
      },
      "id": "tilda-form-to-bitrix24-lead-03",
      "name": "Find duplicate in Bitrix24",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -160,
        40
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://YOUR_PORTAL.bitrix24.ru/rest/CRM_WEBHOOK/crm.lead.add.json",
        "sendBody": true,
        "contentType": "json",
        "bodyParameters": {
          "parameters": []
        }
      },
      "id": "tilda-form-to-bitrix24-lead-04",
      "name": "Create or update Bitrix24 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-bitrix24-lead-05",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        400,
        40
      ]
    }
  ],
  "connections": {
    "Webhook input": {
      "main": [
        [
          {
            "node": "Normalize and map Bitrix24 fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize and map Bitrix24 fields": {
      "main": [
        [
          {
            "node": "Find duplicate in Bitrix24",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find duplicate in Bitrix24": {
      "main": [
        [
          {
            "node": "Create or update Bitrix24 lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create or update Bitrix24 lead": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    {
      "name": "nodbot"
    },
    {
      "name": "tilda"
    },
    {
      "name": "bitrix24"
    },
    {
      "name": "lead"
    },
    {
      "name": "utm"
    }
  ],
  "triggerCount": 0,
  "updatedAt": "2026-05-30T00:00:00.000Z",
  "versionId": "nodbot-tilda-form-to-bitrix24-lead-problem-solution-v1",
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "notes": "Problem/Solution-мануал по интеграции Tilda и Битрикс24 через n8n: настройка вебхука, передача данных из формы, crm.duplicate.findbycomm, UTM-поля, нормализация телефона и production-проверка. Replace credentials, endpoints and custom field IDs before production."
}