{
  "name": "Autonomous Lead Sourcing Engine",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "id": "0d918216-b109-4a58-86f6-60bfd579c139",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1680,
        480
      ],
      "typeVersion": 3
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-5-mini",
          "mode": "list",
          "cachedResultName": "gpt-5-mini"
        },
        "options": {}
      },
      "id": "92bdb02e-7c78-4a6e-bef8-0703d41d2a33",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1984,
        352
      ],
      "typeVersion": 1.2,
      "credentials": {
        "openAiApi": {
          "id": "6LnEKBlR3JCiWGdk",
          "name": "OpenAi account"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "2a1b191a-c6dd-4f77-b7e3-9c54d655e08a",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.totalScore }}",
              "rightValue": 3.5
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "299adca5-d101-4d2a-8885-bb02e2c4a972",
      "name": "Filter Reviews",
      "type": "n8n-nodes-base.filter",
      "position": [
        896,
        624
      ],
      "typeVersion": 2.2
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a58d8634-f3b3-4aa7-af9b-2170b18d064c",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.Website }}",
              "rightValue": "not"
            }
          ]
        },
        "options": {}
      },
      "id": "bfc23b9a-41c5-407a-b76a-340b19247f51",
      "name": "Filter Website",
      "type": "n8n-nodes-base.filter",
      "position": [
        1312,
        624
      ],
      "typeVersion": 2.2
    },
    {
      "parameters": {
        "jsCode": "const newData = $('Scrape Maps').all();\nconst existing = $('Get Saved Leads').all();\n\n// Build a set of existing titles (case-insensitive, trimmed)\nconst existingTitles = new Set(\n  existing\n    .map(e => (e.json.Title || e.json.title || '').toLowerCase().trim())\n    .filter(Boolean)\n);\n\n// Filter new data that is NOT already in the sheet\nconst filtered = newData.filter(b => {\n  const name = (b.json.title || b.json.Title || '').toLowerCase().trim();\n  return name && !existingTitles.has(name);\n});\n\n// If no new leads, return a clear message\nif (filtered.length === 0) {\n  return [{\n    json: {\n      message: 'No new leads found',\n      status: 'stopped'\n    }\n  }];\n}\n\nreturn filtered;\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        768,
        624
      ],
      "id": "253cd14d-88c1-4e5e-9ee3-0a45e9bcc067",
      "name": "Filter Duplicates",
      "alwaysOutputData": true,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "amount": "={{ $json.delaySeconds }}"
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2080,
        736
      ],
      "id": "89b75da4-146d-4a74-b74b-ec258db7d910",
      "name": "Wait",
      "webhookId": "e5cf2e6f-5272-498d-8888-b08a197787e0"
    },
    {
      "parameters": {
        "jsCode": "// Generate a random delay between 1 and 5 seconds (including decimals)\nconst min = 1;  // minimum seconds\nconst max = 5;  // maximum seconds\n\n// Create random decimal delay, e.g. 1.7 or 4.3 seconds\nconst delaySeconds = (Math.random() * (max - min) + min).toFixed(1);\n\n// Pass to the next node\nreturn [{ delaySeconds }];\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1952,
        736
      ],
      "id": "d87fec63-82a3-4108-8002-386d2baa6a40",
      "name": "Random Delay"
    },
    {
      "parameters": {
        "formTitle": "Generate Leads",
        "formFields": {
          "values": [
            {
              "fieldLabel": "What is your search term?",
              "requiredField": true
            },
            {
              "fieldLabel": "What location/city you want to search?",
              "requiredField": true
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.3,
      "position": [
        352,
        624
      ],
      "id": "cdbdf44e-23f9-4500-85cd-1eda38445d49",
      "name": "On form submission",
      "webhookId": "b2787ecc-528b-4f92-9840-e15b184076e2"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/acts/compass~crawler-google-places/run-sync-get-dataset-items?token=apify_api_UTQaFhhVG6hHRqUcOPIykGdrcDXGAy1U1AYm",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "Bearer INSERT_YOUR_API_KEY"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n    \"includeWebResults\": false,\n    \"language\": \"en\",\n    \"locationQuery\": \"{{ $json['What location/city you want to search?'] }}\",\n    \"maxCrawledPlacesPerSearch\": 10,\n    \"maxImages\": 0,\n    \"maximumLeadsEnrichmentRecords\": 0,\n    \"scrapeContacts\": false,\n    \"scrapeDirectories\": false,\n    \"scrapeImageAuthors\": false,\n    \"scrapePlaceDetailPage\": false,\n    \"scrapeReviewsPersonalData\": true,\n    \"scrapeTableReservationProvider\": false,\n    \"searchStringsArray\": [\n        \"{{ $json['What is your search term?'] }}\"\n    ],\n    \"skipClosedPlaces\": false\n}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "id": "98e6abab-774f-479b-ad15-20c4e8e262ec",
      "name": "Scrape Maps",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        496,
        624
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1OXtl-BsZsuVrCKZvOE57v-jLjSBzamNKIr2ZvpMaH4c",
          "mode": "list",
          "cachedResultName": "Lead Scraper",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OXtl-BsZsuVrCKZvOE57v-jLjSBzamNKIr2ZvpMaH4c/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OXtl-BsZsuVrCKZvOE57v-jLjSBzamNKIr2ZvpMaH4c/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        624,
        624
      ],
      "id": "1313dfc8-f593-4cf3-8480-58948fae009d",
      "name": "Get Saved Leads",
      "executeOnce": true,
      "alwaysOutputData": true,
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "uJs2j7wVby6KZmho",
          "name": "Google Sheets account 9"
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1OXtl-BsZsuVrCKZvOE57v-jLjSBzamNKIr2ZvpMaH4c",
          "mode": "list",
          "cachedResultName": "Lead Scraper",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OXtl-BsZsuVrCKZvOE57v-jLjSBzamNKIr2ZvpMaH4c/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OXtl-BsZsuVrCKZvOE57v-jLjSBzamNKIr2ZvpMaH4c/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Date": "={{ $now }}",
            "Title": "={{ $json.title }}",
            "Street": "={{ $json.street }}",
            "City": "={{ $json.city }}",
            "Website": "={{ $json.website }}",
            "State": "={{ $json.state }}",
            "Phone": "={{ $json.phone }}",
            "Category": "={{ $json.categoryName }}",
            "Reviews": "={{ $json.reviewsCount }}",
            "Rating": "={{ $json.totalScore }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Date",
              "displayName": "Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Category",
              "displayName": "Category",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Title",
              "displayName": "Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "State",
              "displayName": "State",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "City",
              "displayName": "City",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Street",
              "displayName": "Street",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website",
              "displayName": "Website",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "displayName": "Phone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Rating",
              "displayName": "Rating",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Reviews",
              "displayName": "Reviews",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Facebook",
              "displayName": "Facebook",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "LinkedIn",
              "displayName": "LinkedIn",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Twitter",
              "displayName": "Twitter",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Instagram",
              "displayName": "Instagram",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "TikTok",
              "displayName": "TikTok",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "YouTube",
              "displayName": "YouTube",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Yelp",
              "displayName": "Yelp",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Message",
              "displayName": "Message",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "id": "30f6f284-641a-4a65-ab2d-f37ffe6725a1",
      "name": "Save New Leads",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1040,
        624
      ],
      "typeVersion": 4.6,
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "uJs2j7wVby6KZmho",
          "name": "Google Sheets account 9"
        }
      }
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1OXtl-BsZsuVrCKZvOE57v-jLjSBzamNKIr2ZvpMaH4c",
          "mode": "list",
          "cachedResultName": "Lead Scraper",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OXtl-BsZsuVrCKZvOE57v-jLjSBzamNKIr2ZvpMaH4c/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OXtl-BsZsuVrCKZvOE57v-jLjSBzamNKIr2ZvpMaH4c/edit#gid=0"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Status",
              "lookupValue": "="
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1184,
        624
      ],
      "id": "99ece2a0-1811-41d8-8c42-903da0f18364",
      "name": "Get New Leads",
      "executeOnce": true,
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "uJs2j7wVby6KZmho",
          "name": "Google Sheets account 9"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const html = $input.first().json.data.html;\n\n// Email regex\nconst emailRegex = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}/gi;\n\n// Social regexes\nconst socialRegexes = {\n  facebook: /(https?:\\/\\/(?:www\\.)?(?:facebook|fb)\\.com\\/[^\\s\"')]+)/gi,\n  instagram: /(https?:\\/\\/(?:www\\.)?(?:instagram|ig)\\.com\\/[^\\s\"')]+)/gi,\n  linkedin: /(https?:\\/\\/(?:www\\.)?linkedin\\.com\\/[^\\s\"')]+)/gi,\n  x: /(https?:\\/\\/(?:www\\.)?(?:x\\.com|twitter\\.com)\\/[^\\s\"')]+)/gi,\n  tiktok: /(https?:\\/\\/(?:www\\.)?tiktok\\.com\\/[^\\s\"')]+)/gi,\n  youtube: /(https?:\\/\\/(?:www\\.)?(?:youtube\\.com|youtu\\.be)\\/[^\\s\"')]+)/gi,\n};\n\n// Extract ALL valid emails\nlet emails = [];\nconst foundEmails = html.match(emailRegex);\nif (foundEmails) {\n  // Filter out junk emails\n  const validEmails = foundEmails.filter(e =>\n    !e.includes('example.com') &&\n    !e.endsWith('.jpg') &&\n    !e.endsWith('.png') &&\n    !e.endsWith('.svg') &&\n    !e.endsWith('.gif') &&\n    !e.includes('sentry.io') &&\n    !e.includes('schema.org') &&\n    !e.includes('w3.org')\n  );\n  \n  // Remove duplicates (case-insensitive)\n  const uniqueEmails = [...new Set(validEmails.map(e => e.toLowerCase()))];\n  emails = uniqueEmails;\n}\n\n// Extract ALL social links per platform (deduplicated)\nconst socials = {};\nfor (const [name, regex] of Object.entries(socialRegexes)) {\n  const matches = [...html.matchAll(regex)];\n  if (matches.length > 0) {\n    // Get all URLs, clean them, deduplicate\n    const urls = matches\n      .map(m => m[0].trim().replace(/[\\])}>,\"\\s]+$/, ''))\n      .filter((url, index, self) => self.indexOf(url) === index); // Remove duplicates\n    socials[name] = urls.join(', '); // Join multiple with comma\n  } else {\n    socials[name] = 'Not found';\n  }\n}\n\n// Build final flat object\nconst output = {\n  email: emails.length > 0 ? emails.join(', ') : 'Not found', // Join all emails with comma\n  facebook: socials.facebook,\n  instagram: socials.instagram,\n  linkedin: socials.linkedin,\n  x: socials.x,\n  tiktok: socials.tiktok,\n  youtube: socials.youtube\n};\n\n// Return flat key/value fields\nreturn [{ json: output }];"
      },
      "id": "c02f0ee1-7af7-4278-99b2-5595d8ff3c65",
      "name": "Extract Info",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1824,
        736
      ],
      "onError": "continueRegularOutput",
      "notes": "Extracts email addresses from website HTML"
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1OXtl-BsZsuVrCKZvOE57v-jLjSBzamNKIr2ZvpMaH4c",
          "mode": "list",
          "cachedResultName": "Lead Scraper",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OXtl-BsZsuVrCKZvOE57v-jLjSBzamNKIr2ZvpMaH4c/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OXtl-BsZsuVrCKZvOE57v-jLjSBzamNKIr2ZvpMaH4c/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Website": "={{ $('Filter Website').item.json.Website }}",
            "Email": "={{ $('Extract Info').item.json.email }}",
            "Facebook": "={{ $('Extract Info').item.json.facebook }}",
            "LinkedIn": "={{ $('Extract Info').item.json.linkedin }}",
            "Instagram": "={{ $('Extract Info').item.json.instagram }}",
            "Twitter": "={{ $('Extract Info').item.json.x }}",
            "TikTok": "={{ $('Extract Info').item.json.tiktok }}",
            "YouTube": "={{ $('Extract Info').item.json.youtube }}"
          },
          "matchingColumns": [
            "Website"
          ],
          "schema": [
            {
              "id": "Date",
              "displayName": "Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Category",
              "displayName": "Category",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Title",
              "displayName": "Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "State",
              "displayName": "State",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "City",
              "displayName": "City",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Street",
              "displayName": "Street",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Website",
              "displayName": "Website",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Phone",
              "displayName": "Phone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Rating",
              "displayName": "Rating",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Reviews",
              "displayName": "Reviews",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Facebook",
              "displayName": "Facebook",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "LinkedIn",
              "displayName": "LinkedIn",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Twitter",
              "displayName": "Twitter",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Instagram",
              "displayName": "Instagram",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "TikTok",
              "displayName": "TikTok",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "YouTube",
              "displayName": "YouTube",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Yelp",
              "displayName": "Yelp",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Message",
              "displayName": "Message",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "id": "7184af59-ee6e-4e55-b6b0-d81b0675f556",
      "name": "Add Info to Leads",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2208,
        736
      ],
      "typeVersion": 4.6,
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "uJs2j7wVby6KZmho",
          "name": "Google Sheets account 9"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=You are an expert at writing friendly, casual cold outreach emails.\n\nAvailable info:\nCategory: {{ $('Get New Leads').item.json.Category }}\nBusiness Name: {{ $('Get New Leads').item.json.Title }}\nRating: {{ $('Get New Leads').item.json.Rating }}\nReview Count: {{ $('Get New Leads').item.json.Reviews }}\n\nEXAMPLE EMAIL TO MODEL (follow this EXACT style and structure):\n\n---\nHi Best Spa team,\n\nYou are doing a great job as Category!\n\nI checked out your [Rating]-star rating with [Review count] reviews and customers are very happy ;)\n\nWould you like to know how to get 30% more bookings while reducing no shows by 50%?\n\nI just made a quick video for you sharing how you can do this.\n\nI'm YOUR_NAME, an AI systems expert helping [Category] businesses increase revenue and cut costs.\n\nJust reply \"yes\" and I send over the video ;)\n\nYOUR_NAME\n\n---\n\nYOUR TASK:\nWrite an email following the EXACT structure above, but personalize it for:\n- Business Name: {{ $('Get New Leads').item.json.Title }}\n- Category: {{ $('Get New Leads').item.json.Category }}\n- Rating: {{ $('Get New Leads').item.json.Rating }} stars\n- Reviews: {{ $('Get New Leads').item.json.Reviews }} reviews\n\nRULES:\n1. Keep the same casual, friendly tone\n2. ONE sentence per line with empty lines between\n3. Use emojis sparingly (like ;) or :))\n4. Replace \"Best Spa\" with the actual business name\n5. Replace \"spas\" with the actual category\n6. Reference their rating/reviews in line 3\n7. Keep everything else exactly the same\n8. Do NOT add extra sentences or change the structure\n9. for the greeting use the name of the business but if the name includes multiple infos make sure to keep it simple so the greeting doesn't look weird. Example: if business name is \"Hi Neil G Carousso, CPA, CFP team\" in the greeting only say \"Hey Mr Carousso\" or \"Hey Carousso Team\" use \"team\" if the business name is NOT a personal name\n\nOutput ONLY the email, nothing else.",
        "options": {}
      },
      "id": "0de5b847-da68-4325-857b-b4a26c0a6fb2",
      "name": "Email Generator",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1904,
        464
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1OXtl-BsZsuVrCKZvOE57v-jLjSBzamNKIr2ZvpMaH4c",
          "mode": "list",
          "cachedResultName": "Lead Scraper",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OXtl-BsZsuVrCKZvOE57v-jLjSBzamNKIr2ZvpMaH4c/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OXtl-BsZsuVrCKZvOE57v-jLjSBzamNKIr2ZvpMaH4c/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Website": "={{ $('Loop Over Items').item.json.Website }}",
            "Message": "={{ $json.output }}",
            "Status": "Processed"
          },
          "matchingColumns": [
            "Website"
          ],
          "schema": [
            {
              "id": "Date",
              "displayName": "Date",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Category",
              "displayName": "Category",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Title",
              "displayName": "Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "State",
              "displayName": "State",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "City",
              "displayName": "City",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Street",
              "displayName": "Street",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Website",
              "displayName": "Website",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Phone",
              "displayName": "Phone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Rating",
              "displayName": "Rating",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Reviews",
              "displayName": "Reviews",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Facebook",
              "displayName": "Facebook",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "LinkedIn",
              "displayName": "LinkedIn",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Twitter",
              "displayName": "Twitter",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Instagram",
              "displayName": "Instagram",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "TikTok",
              "displayName": "TikTok",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "YouTube",
              "displayName": "YouTube",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Yelp",
              "displayName": "Yelp",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Message",
              "displayName": "Message",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "useAppend": true
        }
      },
      "id": "5f44b889-dfff-4f98-8709-e152507aa6be",
      "name": "Add Email to Lead",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2208,
        464
      ],
      "typeVersion": 4.6,
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "uJs2j7wVby6KZmho",
          "name": "Google Sheets account 9"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "INSERT_YOUR_EMAIL",
        "subject": "=New Leads \"{{ $('On form submission').item.json['What is your search term?'] }}\" in \"{{ $('On form submission').item.json['What location/city you want to search?'] }}\"",
        "message": "=New Leads for \"{{ $('On form submission').item.json['What is your search term?'] }}\" in \"{{ $('On form submission').item.json['What location/city you want to search?'] }}\" were added to your sheet!",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        2064,
        160
      ],
      "id": "570498fe-0673-4bb6-8e54-fc9f58928338",
      "name": "Send completion note",
      "webhookId": "a83f40b8-d8d1-463b-a7e3-936a05dd719d",
      "executeOnce": true,
      "credentials": {
        "gmailOAuth2": {
          "id": "I2ZG9c2iSpAzX2S0",
          "name": "Gmail account 9"
        }
      }
    },
    {
      "parameters": {
        "content": "## Find New Leads",
        "height": 224,
        "width": 1104
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        320,
        560
      ],
      "id": "555a18fc-0743-40b9-915a-e4a2f25f3043",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.firecrawl.dev/v1/scrape",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer INSERT_YOUR_API_KEY"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"url\": \"{{ $json.Website }}\",\n  \"formats\": [\n    \"markdown\",\n    \"html\"\n  ]\n} ",
        "options": {}
      },
      "id": "1a397f80-3f3b-468d-a8e6-dd5cb8e0e953",
      "name": "Scrape Website Content",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1664,
        736
      ],
      "typeVersion": 4.2,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "content": "## Get Email and Socials",
        "height": 240,
        "width": 752,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1616,
        688
      ],
      "id": "cb134fb3-2de9-4856-bf41-f80a4c88a157",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "cc7d1ee1-bc3f-4f5e-a06d-7a7514703991",
      "name": "Batch Processing",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1488,
        624
      ],
      "typeVersion": 3
    },
    {
      "parameters": {
        "content": "## Generate Outreach Email",
        "height": 368,
        "width": 752,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1616,
        304
      ],
      "id": "5f9b205f-bf2d-4fc2-82d8-e87d8d826960",
      "name": "Sticky Note2"
    }
  ],
  "connections": {
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Send completion note",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Email Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Email Generator",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Filter Reviews": {
      "main": [
        [
          {
            "node": "Save New Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Website": {
      "main": [
        [
          {
            "node": "Batch Processing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Duplicates": {
      "main": [
        [
          {
            "node": "Filter Reviews",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Random Delay": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Add Info to Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Scrape Maps",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Maps": {
      "main": [
        [
          {
            "node": "Get Saved Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Saved Leads": {
      "main": [
        [
          {
            "node": "Filter Duplicates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save New Leads": {
      "main": [
        [
          {
            "node": "Get New Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get New Leads": {
      "main": [
        [
          {
            "node": "Filter Website",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Info": {
      "main": [
        [
          {
            "node": "Random Delay",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Info to Leads": {
      "main": [
        [
          {
            "node": "Batch Processing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Generator": {
      "main": [
        [
          {
            "node": "Add Email to Lead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Email to Lead": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Website Content": {
      "main": [
        [
          {
            "node": "Extract Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Batch Processing": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Scrape Website Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "84de6995-d5a0-461a-927e-05a5a6f70065",
  "meta": {
    "templateId": "6091",
    "templateCredsSetupCompleted": true,
    "instanceId": "7ff6625f0127f3e9a7865e3493009de1c48f57dc5ed87def3ae3316be7f6b238"
  },
  "id": "0DQLzLLf6sJs8oUm",
  "tags": []
}