{
  "name": "Automate lead generation from Google Search & Maps to Google Sheets",
  "nodes": [
    {
      "id": "9f1247da-3797-481a-b835-a5c780b050d4",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -1344,
        496
      ]
    },
    {
      "id": "f8df5c5f-af30-4f62-9aab-e010dd9c9c91",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        256,
        -96
      ]
    },
    {
      "id": "a496c6f6-fa85-4a33-85f4-98e9b00f4af2",
      "name": "Append row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        880,
        -128
      ]
    },
    {
      "id": "82cf4f94-509f-4698-9982-af48caa035de",
      "name": "Remove Duplicates",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        1056,
        1136
      ]
    },
    {
      "id": "ff0491b3-1695-48be-863d-d7e8bd6529cd",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1312,
        1104
      ]
    },
    {
      "id": "d441d472-e687-44d7-9ddb-fb1f8baa7c45",
      "name": "Extract URLs",
      "type": "n8n-nodes-base.code",
      "position": [
        592,
        1120
      ]
    },
    {
      "id": "30354b5f-e671-42fb-be46-38dcd63a6b10",
      "name": "Scrape Google Maps",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        368,
        1136
      ]
    },
    {
      "id": "bdba745f-cec0-4df6-8f95-cff4eb9ea1ff",
      "name": "Filter Google URLs",
      "type": "n8n-nodes-base.filter",
      "position": [
        832,
        1136
      ]
    },
    {
      "id": "ed333dd0-1e0d-4c97-8b63-7535427f8a8d",
      "name": "Wait2",
      "type": "n8n-nodes-base.wait",
      "position": [
        1696,
        1120
      ]
    },
    {
      "id": "34b415fd-db46-4914-b005-236b5aaee205",
      "name": "Get row(s) in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        112,
        448
      ]
    },
    {
      "id": "e631f027-7a37-4899-89d6-0b0c7f18c6fa",
      "name": "Get row(s) in sheet1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        96,
        1760
      ]
    },
    {
      "id": "cb140551-a551-47ae-97b7-d64048c43be6",
      "name": "Remove Duplicates3",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        1296,
        1728
      ]
    },
    {
      "id": "13770160-49fe-4a3e-b60d-81a9ff86368a",
      "name": "Append row in sheet2",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1632,
        1728
      ]
    },
    {
      "id": "a1d0ac38-853a-40f1-8268-201e17d3d82e",
      "name": "Loop Over Items1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        608,
        368
      ]
    },
    {
      "id": "d16c9b61-e5fc-414e-ad4d-6f4b62a3822c",
      "name": "Setting Pagination",
      "type": "n8n-nodes-base.code",
      "position": [
        160,
        -368
      ]
    },
    {
      "id": "37cdc904-b273-49f9-b0f1-e00ec4fe2895",
      "name": "Loop for Multiple Page Search",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        400,
        -368
      ]
    },
    {
      "id": "b05aecbc-243e-418f-ab55-cb20e12f5116",
      "name": "Custom Google Search API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        704,
        -352
      ]
    },
    {
      "id": "79df0f3d-6211-4f5f-9b76-263da7db8edb",
      "name": "Flatten Output Items",
      "type": "n8n-nodes-base.code",
      "position": [
        944,
        -352
      ]
    },
    {
      "id": "2c3e8958-595e-4e11-9d01-158657691667",
      "name": "Information Extraction",
      "type": "n8n-nodes-base.code",
      "position": [
        1280,
        -352
      ]
    },
    {
      "id": "e0d64378-c004-44b3-a9d9-cee43a157989",
      "name": "Remove Duplicates From Searches",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        1680,
        -352
      ]
    },
    {
      "id": "5e59a9c6-6b03-4361-8505-974a74fea15f",
      "name": "Scrape Site2",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        944,
        352
      ]
    },
    {
      "id": "5cc43a8c-9ae5-49e6-8c55-d5e9839424c7",
      "name": "If Site scrapped",
      "type": "n8n-nodes-base.if",
      "position": [
        1248,
        352
      ]
    },
    {
      "id": "81d1f254-b195-4ba3-bf85-f14ad3422a1f",
      "name": "Extract Required Fields",
      "type": "n8n-nodes-base.code",
      "position": [
        1488,
        336
      ]
    },
    {
      "id": "66f68935-9577-4b95-a235-f8a720aa7dc1",
      "name": "Set All Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        1776,
        336
      ]
    },
    {
      "id": "27f9e051-ccde-42a0-974d-806de632135a",
      "name": "Set URL for Validation",
      "type": "n8n-nodes-base.set",
      "position": [
        336,
        448
      ]
    },
    {
      "id": "72008dea-4b9c-4b0a-8df0-befb25c64220",
      "name": "Not Duplicate Search Results",
      "type": "n8n-nodes-base.merge",
      "position": [
        624,
        624
      ]
    },
    {
      "id": "a9063fa4-00fa-4279-be72-df006d6a36ea",
      "name": "If Site Exists",
      "type": "n8n-nodes-base.if",
      "position": [
        928,
        624
      ]
    },
    {
      "id": "64635b25-9b96-4473-b876-c058ef977593",
      "name": "Exclude Articles and Blogs",
      "type": "n8n-nodes-base.if",
      "position": [
        1280,
        624
      ]
    },
    {
      "id": "310820f4-5ebe-436d-9069-ead7678c29fd",
      "name": "Remove Duplicates For Sheets",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        1616,
        608
      ]
    },
    {
      "id": "96c4b66d-f5f4-4026-8ec6-429ab727a10f",
      "name": "Add Search Results in Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1888,
        608
      ]
    },
    {
      "id": "6fccec45-a3b6-420c-b627-33b15b02cbb4",
      "name": "Prepare Query for Maps",
      "type": "n8n-nodes-base.code",
      "position": [
        128,
        1120
      ]
    },
    {
      "id": "b4c0a560-6368-47cc-a9b4-284a4072e2e0",
      "name": "Scrape Map Sites",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1504,
        1120
      ]
    },
    {
      "id": "274a3ed6-18fe-47f9-9571-ddd57bdc31c8",
      "name": "Extract Information",
      "type": "n8n-nodes-base.code",
      "position": [
        1904,
        1104
      ]
    },
    {
      "id": "1575bc32-cf8f-4409-99ee-268f51feba52",
      "name": "Set URL Validaiton",
      "type": "n8n-nodes-base.set",
      "position": [
        368,
        1760
      ]
    },
    {
      "id": "387ef4ed-617a-4421-900f-05c6e84ff7b1",
      "name": "Validating Unique Results",
      "type": "n8n-nodes-base.merge",
      "position": [
        672,
        1744
      ]
    },
    {
      "id": "3e6771bb-fdf6-48ce-a3c5-5e4b49f042fa",
      "name": "If Site exists",
      "type": "n8n-nodes-base.if",
      "position": [
        976,
        1744
      ]
    },
    {
      "id": "e07c2d9a-d9ce-4cc1-9e11-5e502325ac40",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        -656
      ],
      "parameters": {
        "width": 1824,
        "height": 704,
        "content": "## Phase 1: Google Custom Search Branch\n\n \n1. When chat message received: 💬 Chat Input: Captures the user's search query to start the lead generation process.\n2. Setting Pagination: 📄 Google Search Pa"
      }
    },
    {
      "id": "e10066d0-7805-46e1-94fc-b1606477adbf",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        96
      ],
      "parameters": {
        "width": 2032,
        "height": 704,
        "content": "## Phase 2: Google Maps Search Branch\n\n \n1.Prepare Query for Maps: 🗺️ Format Maps Query: Converts the chat input (e.g., \"dentists in New York\") into a URL-friendly format.\n2. Scrape Google Maps: 📍 Goo"
      }
    },
    {
      "id": "60c0c125-0be0-4cb6-8a53-eb7c01ecd83a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        816
      ],
      "parameters": {
        "width": 2032,
        "height": 560,
        "content": "## Phase 3: Data Enrichment & Saving\n\n \n1. If: 🤔 Email Checkpoint: Checks if an email was found; if not, it sends the URL for deeper website scraping.\n2. Loop Over Items1: 🔄 Website Scrape Loop: Proce"
      }
    },
    {
      "id": "e9b69fd8-053b-42e7-9b46-108e987b684c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        1440
      ],
      "parameters": {
        "width": 1808,
        "height": 480,
        "content": "## Phase 4: Final Validation & Output\n\n1. Get row(s) in sheet / Get row(s) in sheet1: 📚 Load Existing Leads: Fetches all previously saved leads from the Google Sheet for deduplication.\n2. Set URL for "
      }
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait2": {
      "main": [
        [
          {
            "node": "Extract Information",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract URLs": {
      "main": [
        [
          {
            "node": "Filter Google URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Site2": {
      "main": [
        [
          {
            "node": "If Site scrapped",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Site Exists": {
      "main": [
        [
          {
            "node": "Exclude Articles and Blogs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Site exists": {
      "main": [
        [
          {
            "node": "Remove Duplicates3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set All Fields": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Validating Unique Results",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Scrape Map Sites",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Site scrapped": {
      "main": [
        [
          {
            "node": "Extract Required Fields",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [
          {
            "node": "Not Duplicate Search Results",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Scrape Site2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Map Sites": {
      "main": [
        [
          {
            "node": "Wait2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicates": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Google URLs": {
      "main": [
        [
          {
            "node": "Remove Duplicates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicates3": {
      "main": [
        [
          {
            "node": "Append row in sheet2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Google Maps": {
      "main": [
        [
          {
            "node": "Extract URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set URL Validaiton": {
      "main": [
        [
          {
            "node": "Validating Unique Results",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Setting Pagination": {
      "main": [
        [
          {
            "node": "Loop for Multiple Page Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Information": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "Set URL for Validation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Flatten Output Items": {
      "main": [
        [
          {
            "node": "Information Extraction",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet1": {
      "main": [
        [
          {
            "node": "Set URL Validaiton",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Information Extraction": {
      "main": [
        [
          {
            "node": "Remove Duplicates From Searches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Query for Maps": {
      "main": [
        [
          {
            "node": "Scrape Google Maps",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set URL for Validation": {
      "main": [
        [
          {
            "node": "Not Duplicate Search Results",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Extract Required Fields": {
      "main": [
        [
          {
            "node": "Set All Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Custom Google Search API": {
      "main": [
        [
          {
            "node": "Flatten Output Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validating Unique Results": {
      "main": [
        [
          {
            "node": "If Site exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Exclude Articles and Blogs": {
      "main": [
        [
          {
            "node": "Remove Duplicates For Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Setting Pagination",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          },
          {
            "node": "Prepare Query for Maps",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get row(s) in sheet1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Not Duplicate Search Results": {
      "main": [
        [
          {
            "node": "If Site Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicates For Sheets": {
      "main": [
        [
          {
            "node": "Add Search Results in Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop for Multiple Page Search": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Custom Google Search API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicates From Searches": {
      "main": [
        [
          {
            "node": "Loop for Multiple Page Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}