{
  "name": "Sync and enrich HubSpot leads from Google Sheets and Telegram with Gemini and Lusha",
  "nodes": [
    {
      "id": "b3f9cc95-e454-4cdd-9457-1a10d3125620",
      "name": "HubSpot: Update Company",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        1088,
        -80
      ]
    },
    {
      "id": "c749a19f-60b8-4153-bd1b-cad2ce0ffab3",
      "name": "HubSpot: Create Company",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        1088,
        112
      ]
    },
    {
      "id": "dae0749e-1756-4e2f-8dcb-4a619f031e3f",
      "name": "Switch Logic",
      "type": "n8n-nodes-base.switch",
      "position": [
        864,
        16
      ]
    },
    {
      "id": "cda80c76-2929-47b2-8a30-ab36db0eadf3",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1248,
        16
      ]
    },
    {
      "id": "a91967fe-b6b0-4c8d-b7bf-c51948a466f3",
      "name": "Parse Telegram Message",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        -1072,
        16
      ]
    },
    {
      "id": "03865301-f09a-4206-96af-68032c0d7238",
      "name": "Get HubSpot data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -400,
        144
      ]
    },
    {
      "id": "668a8f24-e36f-44d8-b8fc-5ce561560430",
      "name": "New or Updated row",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "position": [
        -992,
        -256
      ]
    },
    {
      "id": "03272bd1-5a3c-4ad7-8cd4-1e9287c49939",
      "name": "Create or update a contact",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        2352,
        -32
      ]
    },
    {
      "id": "bed43ccb-4020-484a-8fb9-29f2f09d12bb",
      "name": "Add a Note to Hubspot company",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3152,
        192
      ]
    },
    {
      "id": "64d444d9-cc08-4693-b483-ed7b057bba5a",
      "name": "Identify Telegram triggered flow",
      "type": "n8n-nodes-base.filter",
      "position": [
        2912,
        -192
      ]
    },
    {
      "id": "be37f9e5-dc97-4c54-a543-2a5040fbe343",
      "name": "Update Telegram user",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3152,
        -192
      ]
    },
    {
      "id": "28235c93-0bed-45e2-bd55-5cae8e62b3f6",
      "name": "Identify updated row",
      "type": "n8n-nodes-base.filter",
      "position": [
        2912,
        16
      ]
    },
    {
      "id": "67f093c8-a08d-4c3f-b797-a0afe6bf6a45",
      "name": "Acknowledge in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3152,
        16
      ]
    },
    {
      "id": "809347f1-f6aa-44a9-b738-5d4cac4a7acb",
      "name": "Resolve Company ID",
      "type": "n8n-nodes-base.code",
      "position": [
        1616,
        160
      ]
    },
    {
      "id": "febf99b1-ad06-4e34-a040-7f9183eec6c3",
      "name": "Retry ID resolution",
      "type": "n8n-nodes-base.wait",
      "position": [
        2000,
        160
      ]
    },
    {
      "id": "b14903b4-c785-4fa8-ac7e-430f27c3d77d",
      "name": "Filter processed lines",
      "type": "n8n-nodes-base.filter",
      "position": [
        -768,
        -160
      ]
    },
    {
      "id": "280f3542-98f7-4924-9bd5-872cb13c75a8",
      "name": "Lusha Enrichment - email",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1536,
        -192
      ]
    },
    {
      "id": "55404dac-a87f-4f06-acd8-0352a7603413",
      "name": "Switch on email field",
      "type": "n8n-nodes-base.switch",
      "position": [
        1280,
        16
      ]
    },
    {
      "id": "5df0e6c1-3925-4179-9f85-78eb6867b790",
      "name": "Lusha Company Enrichment",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2176,
        -240
      ]
    },
    {
      "id": "a49df86f-40c5-49a9-8dd5-42fd01530240",
      "name": "HubSpot: Update Enriched Company",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2688,
        -240
      ]
    },
    {
      "id": "f29ad8a0-f502-4a46-87a3-8c92715afe60",
      "name": "Domain Resolver",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        -400,
        -224
      ]
    },
    {
      "id": "ecd01c50-610e-4a1e-a918-924a087c2d58",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        304,
        -1264
      ],
      "parameters": {
        "width": 1344,
        "height": 544,
        "content": "# HubSpot Smart Lead Enrichment and Matching via Google Sheets, Telegram, Lusha, and Gemini AI\n\n## Core Architecture - Agnostic Data Structure\n### This architecure is designed to be data-source agnost"
      }
    },
    {
      "id": "d5f6dee6-9157-48a3-8d96-dcbe226b954d",
      "name": "Match Lead to Existing Company",
      "type": "n8n-nodes-base.code",
      "position": [
        640,
        16
      ]
    },
    {
      "id": "a73a4e63-36ec-4c20-b278-90145b7e08dc",
      "name": "Append Resolved Domain to Lead",
      "type": "n8n-nodes-base.merge",
      "position": [
        48,
        -112
      ]
    },
    {
      "id": "59045d18-c3d5-4b71-9768-9e025abc1f58",
      "name": "Combine Lead with CRM Reference Data",
      "type": "n8n-nodes-base.merge",
      "position": [
        384,
        16
      ]
    },
    {
      "id": "b0db6f88-bbc9-473a-88cd-ba005f7af711",
      "name": "Split HubSpot Search Results",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -176,
        144
      ]
    },
    {
      "id": "6c118aab-9f82-4575-a9e3-a8068a4fc35a",
      "name": "Mark as HubSpot Reference Data",
      "type": "n8n-nodes-base.code",
      "position": [
        48,
        144
      ]
    },
    {
      "id": "d3c7dccd-1f22-477c-b330-59ea626ce024",
      "name": "Format Telegram Lead Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -768,
        16
      ]
    },
    {
      "id": "f49edeef-6865-4dfc-abf5-02a696c64ace",
      "name": "Map Contact Enrichment Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1744,
        -192
      ]
    },
    {
      "id": "9bd9f4dc-a08e-40ff-a221-061b2e0b4582",
      "name": "Prepare Firmographic Updates",
      "type": "n8n-nodes-base.code",
      "position": [
        2352,
        -240
      ]
    },
    {
      "id": "21809c08-2b0a-4efc-b715-b18545319b83",
      "name": "Validate Company ID Status",
      "type": "n8n-nodes-base.switch",
      "position": [
        1984,
        -48
      ]
    },
    {
      "id": "d87039fd-c6c2-470b-a815-910326e633a6",
      "name": "Check for Existing Contact Email",
      "type": "n8n-nodes-base.switch",
      "position": [
        2176,
        112
      ]
    },
    {
      "id": "77482f41-01e3-4aa1-b660-e34e3cc5ae3f",
      "name": "Filter Leads with Data Changes",
      "type": "n8n-nodes-base.filter",
      "position": [
        2512,
        -240
      ]
    },
    {
      "id": "ad741b53-69bb-46ea-818b-93d08c11762f",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1312,
        -544
      ],
      "parameters": {
        "width": 704,
        "height": 912,
        "content": "## 1. Data Intake & Parsing \n\n###  These nodes capture new leads from Google Sheets (polling) or Telegram (webhooks). \n### Gemini AI parses unstructured messages into a standard JSON payload, ensuring"
      }
    },
    {
      "id": "847000e9-4adb-4675-850a-f06f87f0355e",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -544
      ],
      "parameters": {
        "width": 656,
        "height": 912,
        "content": "## 2. Contextual Lookup \n\n### Uses Gemini AI to resolve missing corporate domains and fetches existing company data from HubSpot. \n\n### This preparation is key for accurate matching and prevents CRM f"
      }
    },
    {
      "id": "31f1f6fd-6666-4001-8ada-d9729e4d8a87",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        -544
      ],
      "parameters": {
        "width": 464,
        "height": 912,
        "content": "## 3. The Matching Engine \n\n### Custom JS logic performs fuzzy matching against HubSpot data. \n### It calculates a similarity score to determine if a lead belongs to an existing record, optimizing enr"
      }
    },
    {
      "id": "373662ca-70b1-4cba-be0d-cfe4f1bae360",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        -544
      ],
      "parameters": {
        "width": 560,
        "height": 912,
        "content": "## 4. CRM Routing & Core Writes \n\n### This stage directs the lead based on its score: high scores trigger the HubSpot: Update Company node to refresh existing records, while low scores route to HubSpo"
      }
    },
    {
      "id": "55380460-9aba-44e8-a389-76f941d18bae",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1472,
        -544
      ],
      "parameters": {
        "width": 1360,
        "height": 912,
        "content": "## 5. Contact & Firmographic Enrichment \n\n### This stage uses Lusha API to find missing emails and firmographic data (revenue, year founded). \n### It automatically updates the HubSpot company and asso"
      }
    },
    {
      "id": "50c9961d-374b-4723-a623-30cff6a54806",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2880,
        -544
      ],
      "parameters": {
        "width": 448,
        "height": 912,
        "content": "## 6. Feedback Loop \n\n### This final stage of the workflow closes the execution by \n### - Logging the interaction as a HubSpot Note\n### - Updating the original Google Sheet status to 'Processed'\n### -"
      }
    }
  ],
  "connections": {
    "Switch Logic": {
      "main": [
        [
          {
            "node": "HubSpot: Update Company",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HubSpot: Create Company",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Domain Resolver": {
      "main": [
        [
          {
            "node": "Append Resolved Domain to Lead",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Get HubSpot data": {
      "main": [
        [
          {
            "node": "Split HubSpot Search Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Parse Telegram Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New or Updated row": {
      "main": [
        [
          {
            "node": "Filter processed lines",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Resolve Company ID": {
      "main": [
        [
          {
            "node": "Validate Company ID Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retry ID resolution": {
      "main": [
        [
          {
            "node": "Resolve Company ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Identify updated row": {
      "main": [
        [
          {
            "node": "Acknowledge in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch on email field": {
      "main": [
        [
          {
            "node": "Lusha Enrichment - email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Resolve Company ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter processed lines": {
      "main": [
        [
          {
            "node": "Get HubSpot data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Domain Resolver",
            "type": "main",
            "index": 0
          },
          {
            "node": "Append Resolved Domain to Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Telegram Message": {
      "main": [
        [
          {
            "node": "Format Telegram Lead Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HubSpot: Create Company": {
      "main": [
        [
          {
            "node": "Switch on email field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HubSpot: Update Company": {
      "main": [
        [
          {
            "node": "Switch on email field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lusha Company Enrichment": {
      "main": [
        [
          {
            "node": "Prepare Firmographic Updates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lusha Enrichment - email": {
      "main": [
        [
          {
            "node": "Map Contact Enrichment Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Telegram Lead Data": {
      "main": [
        [
          {
            "node": "Get HubSpot data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Combine Lead with CRM Reference Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create or update a contact": {
      "main": [
        [
          {
            "node": "Identify Telegram triggered flow",
            "type": "main",
            "index": 0
          },
          {
            "node": "Identify updated row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Company ID Status": {
      "main": [
        [
          {
            "node": "Retry ID resolution",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Add a Note to Hubspot company",
            "type": "main",
            "index": 0
          },
          {
            "node": "Check for Existing Contact Email",
            "type": "main",
            "index": 0
          },
          {
            "node": "Lusha Company Enrichment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Contact Enrichment Data": {
      "main": [
        [
          {
            "node": "Resolve Company ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Firmographic Updates": {
      "main": [
        [
          {
            "node": "Filter Leads with Data Changes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split HubSpot Search Results": {
      "main": [
        [
          {
            "node": "Mark as HubSpot Reference Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append Resolved Domain to Lead": {
      "main": [
        [
          {
            "node": "Combine Lead with CRM Reference Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Leads with Data Changes": {
      "main": [
        [
          {
            "node": "HubSpot: Update Enriched Company",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark as HubSpot Reference Data": {
      "main": [
        [
          {
            "node": "Combine Lead with CRM Reference Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Match Lead to Existing Company": {
      "main": [
        [
          {
            "node": "Switch Logic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for Existing Contact Email": {
      "main": [
        [
          {
            "node": "Create or update a contact",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Identify Telegram triggered flow",
            "type": "main",
            "index": 0
          },
          {
            "node": "Identify updated row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Identify Telegram triggered flow": {
      "main": [
        [
          {
            "node": "Update Telegram user",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Lead with CRM Reference Data": {
      "main": [
        [
          {
            "node": "Match Lead to Existing Company",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}