{
  "meta": {
    "templateId": "5385"
  },
  "nodes": [
    {
      "id": "47d741e7-a53f-40c7-bf7c-09a446b0d229",
      "name": "Remove Duplicates",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        1168,
        544
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "6cd049c8-425e-45e0-8d45-6a4883c2f496",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        336,
        848
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "3c3a3870-034d-4147-936a-4b0f19b7727d",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        512,
        1056
      ],
      "parameters": {
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "id": "5f4ae91a-29c7-4fb3-b535-34bc5194b183",
      "name": "Wait1",
      "type": "n8n-nodes-base.wait",
      "position": [
        496,
        800
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "645bf31c-4b3c-4f4c-b90b-610fc2d6007c",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        864,
        800
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "emails"
      },
      "typeVersion": 1
    },
    {
      "id": "7e9c227c-2321-429a-a3f3-4c3a77bc6cf3",
      "name": "Extract Emails",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        688,
        1056
      ],
      "parameters": {
        "jsCode": "const input = $input.first().json.data\nconst regex = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.(?!jpeg|jpg|png|gif|webp|svg)[a-zA-Z]{2,}/g\nconst emails = input.match(regex)\nreturn {json: {emails:emails}}"
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "fb76c70c-385d-4e7f-93cd-43023690076a",
      "name": "Extract URLs",
      "type": "n8n-nodes-base.code",
      "position": [
        832,
        544
      ],
      "parameters": {
        "jsCode": "const input = $input.first().json.data\nconst regex = /https?:\\/\\/[^\\/\\s\"'>]+/g\nconst websites = input.match(regex)\nreturn websites.map(website => ({json:{website}}))"
      },
      "typeVersion": 2
    },
    {
      "id": "b10c0ed6-5a94-4272-b65c-bd19bd674fa0",
      "name": "Scrape Google Maps",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        576,
        544
      ],
      "parameters": {
        "url": "=https://www.google.com/maps/search/{{ $json.chatInput }}",
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          },
          "allowUnauthorizedCerts": true
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "58a0d85d-f6eb-47d1-ba9c-3af69ddd30fb",
      "name": "Scrape Site",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        336,
        1056
      ],
      "parameters": {
        "url": "={{ $json.website }}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4618e775-d14d-4355-b3a2-cd6a6bbc70e8",
      "name": "Filter Out Empties",
      "type": "n8n-nodes-base.filter",
      "position": [
        672,
        800
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a6786c58-424a-409a-b87f-8a7592cb7944",
              "operator": {
                "type": "array",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.emails }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "74513e7e-a7dc-4b19-b23e-01efd82c9d6d",
      "name": "Filter Google URLs",
      "type": "n8n-nodes-base.filter",
      "position": [
        992,
        544
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "bf0a5053-9660-457c-9581-964793bb6d7d",
              "operator": {
                "type": "string",
                "operation": "notContains"
              },
              "leftValue": "={{ $json.website }}",
              "rightValue": "schema"
            },
            {
              "id": "9110b9e0-12aa-45cc-bde0-9eda8c10970e",
              "operator": {
                "type": "string",
                "operation": "notContains"
              },
              "leftValue": "={{ $json.website }}",
              "rightValue": "google"
            },
            {
              "id": "fb9b6ed6-96a5-4560-ab10-b8a4b9a61a2b",
              "operator": {
                "type": "string",
                "operation": "notContains"
              },
              "leftValue": "={{ $json.website }}",
              "rightValue": "gg"
            },
            {
              "id": "10500c0b-cdbd-4816-aba3-df60d69845dc",
              "operator": {
                "type": "string",
                "operation": "notContains"
              },
              "leftValue": "={{ $json.website }}",
              "rightValue": "gstatic"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "035fbbe8-7758-4c7b-be8e-c1cba8fc48bc",
      "name": "Remove Duplicates (2)",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        1056,
        800
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "aa3e9285-235d-4fda-ab0e-45134cf825dd",
      "name": "Add to Sheet (or whatever you want!)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1264,
        800
      ],
      "parameters": {
        "columns": {
          "value": {
            "emails": "={{ $json.emails }}"
          },
          "schema": [
            {
              "id": "emails",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "emails",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "emails"
          ]
        },
        "options": {
          "useAppend": true
        },
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fcijyZM1oU73i2xUbXYJ4j6RshmVEduOkCJji2SJP68/edit#gid=0",
          "cachedResultName": "emails"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10V7ikaGWmC-U73Z0sWOv1hfwbyMDvYNMS0lxlvA6C8c",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10V7ikaGWmC-U73Z0sWOv1hfwbyMDvYNMS0lxlvA6C8c/edit?usp=drivesdk",
          "cachedResultName": "GMaps Scrapers"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "5ae34016-6347-474d-a95f-d8e2396fa5d0",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        400,
        544
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "794a397c-b98f-4ac7-a149-efd94672f9a0",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        480
      ],
      "parameters": {
        "width": 466,
        "height": 220,
        "content": "## \ud83d\udd0e Step 1: Google Maps Data Scraper"
      },
      "typeVersion": 1
    },
    {
      "id": "221aae1d-3546-42a1-bb2b-f743e02a300f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        816,
        480
      ],
      "parameters": {
        "width": 544,
        "height": 196,
        "content": "## \ud83d\udd17 Step 2: URL Filtering & Processing"
      },
      "typeVersion": 1
    },
    {
      "id": "d914e291-db43-4c45-908d-7d20890294cc",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        976
      ],
      "parameters": {
        "width": 528,
        "height": 248,
        "content": "## \ud83d\udd04 Step 3: Smart Website Scraper"
      },
      "typeVersion": 1
    },
    {
      "id": "a6a902be-648e-41cd-a4fe-00f50cabe78c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        720
      ],
      "parameters": {
        "width": 916,
        "height": 248,
        "content": "## \ud83d\udce7 Step 4: Email Extraction & Data Export\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ac1ba88f-3538-40e9-ad89-84a73da7d239",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        976
      ],
      "parameters": {
        "width": 528,
        "height": 240,
        "content": "## \ud83d\ude80 Get More Resources & Advanced Workflows\n\nFor additional resources, advanced automation tutorials, and business strategies that help you **generate more leads and grow your agency**, check out my website:\n\n##  \ud83d\udc49   [Noman Mohammad](https://nomanmohammad.com)"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Extract Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Filter Out Empties",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Remove Duplicates (2)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Site": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract URLs": {
      "main": [
        [
          {
            "node": "Filter Google URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Emails": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Scrape Site",
            "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
          }
        ]
      ]
    },
    "Filter Out Empties": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Google Maps": {
      "main": [
        [
          {
            "node": "Extract URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicates (2)": {
      "main": [
        [
          {
            "node": "Add to Sheet (or whatever you want!)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Scrape Google Maps",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}