{
  "name": "Nodbot - Bitrix24 integration blueprint with dedupe and UTM",
  "nodes": [
    {
      "parameters": {
        "path": "integration-bitrix24-n8n",
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "id": "0aea393a-0128-4523-a5e6-035c26b459be",
      "name": "Webhook input",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        260
      ]
    },
    {
      "parameters": {
        "jsCode": "const src = $json.body ?? $json;\nconst rawPhone = String(src.phone ?? src.tel ?? '').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 for Bitrix24: ${rawPhone}`);\nconst email = String(src.email ?? '').trim().toLowerCase();\nreturn [{ json: {\n  dedupe: { type: 'PHONE', value: `+${digits}`, email, key: `bitrix24:${digits}:${email || 'no-email'}` },\n  fields: {\n    TITLE: `Новая заявка: ${src.name ?? 'без имени'}`,\n    NAME: String(src.name ?? '').trim(),\n    PHONE: [{ VALUE: `+${digits}`, VALUE_TYPE: 'WORK' }],\n    EMAIL: email ? [{ VALUE: email, VALUE_TYPE: 'WORK' }] : [],\n    COMMENTS: String(src.comment ?? '').trim(),\n    SOURCE_ID: 'WEB',\n    UTM_SOURCE: src.utm_source ?? '', UTM_MEDIUM: src.utm_medium ?? '',\n    UTM_CAMPAIGN: src.utm_campaign ?? '', UTM_CONTENT: src.utm_content ?? '', UTM_TERM: src.utm_term ?? '',\n    UF_CRM_LANDING_PAGE: src.page ?? '', UF_CRM_EXTERNAL_ID: src.external_id ?? ''\n  }\n}}];"
      },
      "id": "11d7f730-29c7-410d-bc2f-9c2ae04a6419",
      "name": "Normalize Bitrix24 lead",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        280,
        260
      ]
    },
    {
      "parameters": {},
      "id": "c64488f9-2ef9-42d0-b832-6296a5b6440b",
      "name": "Find duplicate by phone/email",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        560,
        260
      ]
    },
    {
      "parameters": {},
      "id": "6a23958f-6f26-4398-bce5-959b3fd1f5c0",
      "name": "Create or update CRM item",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        840,
        260
      ]
    },
    {
      "parameters": {},
      "id": "82bb3f2e-5594-4bdc-9d11-63b1860bcc4b",
      "name": "Notify manager",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        1120,
        260
      ]
    },
    {
      "parameters": {},
      "id": "04498977-cb9c-4fe9-8459-a1b9f0c25082",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 2,
      "position": [
        1400,
        260
      ]
    }
  ],
  "connections": {
    "Webhook input": {
      "main": [
        [
          {
            "node": "Normalize Bitrix24 lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Bitrix24 lead": {
      "main": [
        [
          {
            "node": "Find duplicate by phone/email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find duplicate by phone/email": {
      "main": [
        [
          {
            "node": "Create or update CRM item",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create or update CRM item": {
      "main": [
        [
          {
            "node": "Notify manager",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify manager": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    "nodbot",
    "integration",
    "production"
  ],
  "triggerCount": 1,
  "updatedAt": "2026-05-30T00:00:00.000Z",
  "versionId": "fe34419d-217f-4be8-b6f9-86b9c7dbea85",
  "meta": {
    "templateCredsSetupCompleted": false
  }
}