{
  "name": "Nodbot - DaData enrichment before CRM update",
  "nodes": [
    {
      "parameters": {
        "path": "integration-dadata-n8n",
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "id": "b72e8a7f-9a0c-4308-aead-959d8a911c13",
      "name": "Webhook lead input",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        260
      ]
    },
    {
      "parameters": {
        "jsCode": "const src = $json.body ?? $json;\nconst rawPhone = String(src.phone ?? '').trim();\nconst rawEmail = String(src.email ?? '').trim();\nconst rawAddress = String(src.address ?? '').trim();\nconst inn = String(src.inn ?? '').replace(/\\D/g, '');\nconst phoneDigits = rawPhone.replace(/\\D/g, '');\nif (!phoneDigits && !rawEmail && !rawAddress && !inn) {\n  throw new Error('No fields for DaData enrichment');\n}\nreturn [{ json: {\n  lead_id: String(src.lead_id ?? ''),\n  raw: { phone: rawPhone, email: rawEmail, address: rawAddress, inn, name: src.name ?? '' },\n  dadata: {\n    phone: phoneDigits ? [rawPhone] : [],\n    email: rawEmail ? [rawEmail.toLowerCase()] : [],\n    address: rawAddress ? [rawAddress] : [],\n    party_query: inn || String(src.name ?? '').trim()\n  },\n  quality_policy: { auto_update_qc_max: 1, require_phone: true, manual_review_on_qc_geo: [3,4,5] },\n  dedupe_key: phoneDigits ? `phone:${phoneDigits}` : `email:${rawEmail.toLowerCase()}`\n}}];"
      },
      "id": "c20d6f38-78f9-4cc7-8752-a6d66475866b",
      "name": "Prepare DaData request",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        280,
        260
      ]
    },
    {
      "parameters": {},
      "id": "70b7ebc4-6e35-4c24-9ed2-f5ccfe3127e9",
      "name": "Call DaData API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        560,
        260
      ]
    },
    {
      "parameters": {},
      "id": "11ee0cba-211c-4116-873d-15938f760637",
      "name": "Quality gate",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        840,
        260
      ]
    },
    {
      "parameters": {},
      "id": "825c5b01-15f5-4feb-afeb-37aa8d8d4148",
      "name": "Update CRM fields",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        1120,
        260
      ]
    },
    {
      "parameters": {},
      "id": "b7464acc-e1c3-457b-a3f5-b7308adf00b5",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 2,
      "position": [
        1400,
        260
      ]
    }
  ],
  "connections": {
    "Webhook lead input": {
      "main": [
        [
          {
            "node": "Prepare DaData request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare DaData request": {
      "main": [
        [
          {
            "node": "Call DaData API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call DaData API": {
      "main": [
        [
          {
            "node": "Quality gate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Quality gate": {
      "main": [
        [
          {
            "node": "Update CRM fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update CRM fields": {
      "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": "92fd8c6f-6386-43d6-8edb-2ad80e708179",
  "meta": {
    "templateCredsSetupCompleted": false
  }
}