{
  "name": "Sync Facebook leads from Google Sheets to Perfex CRM via REST API",
  "nodes": [
    {
      "id": "2a5fe080-6be9-48f5-bf4b-170e710bc6fe",
      "name": "Schedule trigger (every minute)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1056,
        800
      ]
    },
    {
      "id": "d7e99f65-8311-416c-b6c4-ff295f2255f2",
      "name": "Google Sheets: Get leads with status CREATED",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -848,
        800
      ]
    },
    {
      "id": "c04659e3-0f2b-499e-9a99-974037f33925",
      "name": "Split in batches",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -624,
        800
      ]
    },
    {
      "id": "ae44b21a-bd16-4ae8-963a-0f947188d0f1",
      "name": "Perfex: Search lead by email",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -400,
        800
      ]
    },
    {
      "id": "0fb10fa6-069f-47c5-af3b-3daa232dd36f",
      "name": "IF: Lead exists",
      "type": "n8n-nodes-base.if",
      "position": [
        -176,
        800
      ]
    },
    {
      "id": "f48cc717-5d22-41e7-9148-26440e42de39",
      "name": "IF: Lead not found (404)",
      "type": "n8n-nodes-base.if",
      "position": [
        -544,
        1056
      ]
    },
    {
      "id": "7e0eb121-540d-4147-9147-4bd3ec079a2f",
      "name": "Perfex: Create lead",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -304,
        1040
      ]
    },
    {
      "id": "016bcf2a-6db8-4973-8a86-9af7c6ef8a79",
      "name": "Google Sheets: Mark as ADDED (existing)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        48,
        800
      ]
    },
    {
      "id": "3c52fcc3-3d3a-44e2-9c1a-e83410508453",
      "name": "Google Sheets: Mark as ADDED (new)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -96,
        1040
      ]
    },
    {
      "id": "d2e1139d-6214-4e81-abe2-1cd1881c8fe6",
      "name": "Wait (rate limit buffer)",
      "type": "n8n-nodes-base.wait",
      "position": [
        272,
        800
      ]
    },
    {
      "id": "94dd7d44-a98f-4876-9189-ed2f2cefd1a3",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1728,
        608
      ],
      "parameters": {
        "width": 576,
        "height": 736,
        "content": "## Who’s it for\nThis workflow is for sales and support teams who collect leads from Facebook Lead Ads into Google Sheets and want to automatically sync those leads into Perfex CRM without creating dup"
      }
    },
    {
      "id": "695f41a5-0e72-40ee-8271-4d5653a92763",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -944,
        688
      ],
      "parameters": {
        "width": 304,
        "height": 80,
        "content": "Expected columns + example values + lead_status logic."
      }
    },
    {
      "id": "2cd9145a-f813-4a01-be77-1eafe3fe5930",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -512,
        688
      ],
      "parameters": {
        "width": 304,
        "height": 80,
        "content": "How to generate API token, where to put it (credentials/env), what 404 means."
      }
    },
    {
      "id": "0d066ea4-be01-4dba-96bf-994db1a37455",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        1024
      ],
      "parameters": {
        "width": 150,
        "height": 112,
        "content": "Writes back ADDED + CRM hyperlink, prevents duplicates."
      }
    }
  ],
  "connections": {
    "IF: Lead exists": {
      "main": [
        [
          {
            "node": "Google Sheets: Mark as ADDED (existing)",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Split in batches": {
      "main": [
        [],
        [
          {
            "node": "Perfex: Search lead by email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Perfex: Create lead": {
      "main": [
        [
          {
            "node": "Google Sheets: Mark as ADDED (new)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF: Lead not found (404)": {
      "main": [
        [
          {
            "node": "Perfex: Create lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait (rate limit buffer)": {
      "main": [
        [
          {
            "node": "Split in batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Perfex: Search lead by email": {
      "main": [
        [
          {
            "node": "IF: Lead exists",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "IF: Lead not found (404)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule trigger (every minute)": {
      "main": [
        [
          {
            "node": "Google Sheets: Get leads with status CREATED",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets: Mark as ADDED (new)": {
      "main": [
        [
          {
            "node": "Split in batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets: Mark as ADDED (existing)": {
      "main": [
        [
          {
            "node": "Wait (rate limit buffer)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets: Get leads with status CREATED": {
      "main": [
        [
          {
            "node": "Split in batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}