{
  "name": "Flowprep · Deduplicate leads",
  "active": false,
  "nodes": [
    {
      "id": "deduplicate-leads-start",
      "name": "Start manually",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        300
      ],
      "parameters": {}
    },
    {
      "id": "deduplicate-leads-sample",
      "name": "Sample data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        260,
        300
      ],
      "parameters": {
        "jsCode": "return [\n  {\n    \"email\": \"  ALEX@example.com \",\n    \"name\": \"Alex\"\n  },\n  {\n    \"email\": \"alex@example.com\",\n    \"name\": \"Alex duplicate\"\n  },\n  {\n    \"email\": \"sam@example.com\",\n    \"name\": \"Sam\"\n  }\n].map(json => ({ json }));"
      }
    },
    {
      "id": "deduplicate-leads-transform",
      "name": "Deduplicate leads",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        520,
        300
      ],
      "parameters": {
        "jsCode": "const seen = new Set();\nreturn $input.all().flatMap((item, i) => {\n  const email = String(item.json.email || '').trim().toLowerCase();\n  if (!email || seen.has(email)) return [];\n  seen.add(email);\n  return [{ json: { ...item.json, email }, pairedItem: { item: i } }];\n});"
      }
    },
    {
      "id": "deduplicate-leads-note",
      "name": "Read first",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -30
      ],
      "parameters": {
        "content": "## Deduplicate leads\nNormalize email addresses and keep the first record for each address.\n\n1. Import into n8n.\n2. Execute manually and inspect the output.\n3. Replace Sample data with your source after reviewing the Code node.\n\nThe first row wins. This does not validate email ownership or merge conflicting customer fields.\n\nIndependent example from Flowprep. No credentials or external calls. Sample transformation tested; verify import and execution on your n8n version.",
        "width": 760,
        "height": 230
      }
    }
  ],
  "connections": {
    "Start manually": {
      "main": [
        [
          {
            "node": "Sample data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sample data": {
      "main": [
        [
          {
            "node": "Deduplicate leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "tags": []
}