{
  "id": "dgMapsLeadsSheet1",
  "name": "Google Maps leads to contact details to Google Sheet",
  "nodes": [
    {
      "parameters": {},
      "id": "a2000000-0000-4000-8000-000000000001",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "operation": "findLocalLeads",
        "searches": "plumber in Austin, TX",
        "maxPlacesPerSearch": 10,
        "includeWebsiteContacts": false,
        "includeDecisionMakers": false,
        "leadOptions": {
          "onlyWithWebsite": true
        }
      },
      "id": "a2000000-0000-4000-8000-000000000002",
      "name": "Find Local Leads",
      "type": "n8n-nodes-datagleaner.dataGleaner",
      "typeVersion": 1,
      "position": [
        240,
        0
      ],
      "credentials": {
        "dataGleanerApi": {
          "id": "",
          "name": "Data Gleaner (Apify) API"
        }
      },
      "notesInFlow": true,
      "notes": "Edit the search (one per line, category plus city). Max Places Per Search is billed per place, so it is your cost cap. Website contacts are off here because the next node does that step."
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "a2000000-0000-4000-8000-0000000000a1",
              "leftValue": "={{ !!$json.website && !/^(?:[a-z][a-z0-9+.-]*:\\/\\/)?(?:[^\\/@?#]*@)?(?:[^\\/:?#]+\\.)?(facebook\\.com|fb\\.com|fb\\.me|instagram\\.com|linkedin\\.com|x\\.com|twitter\\.com|tiktok\\.com|youtube\\.com|youtu\\.be|linktr\\.ee)(?:[:\\/?#]|$)/i.test($json.website) }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a2000000-0000-4000-8000-000000000005",
      "name": "Company Website?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        360,
        0
      ],
      "notesInFlow": true,
      "notes": "Places whose website is a Facebook, Instagram, LinkedIn, X, TikTok, YouTube or Linktree page are not company sites, so they skip Get Contact Details (no wasted run, no error) and go straight to the sheet with empty email columns."
    },
    {
      "parameters": {
        "operation": "getContactDetails",
        "websites": "={{ $json.website }}",
        "contactOptions": {
          "maxPagesPerSite": 4
        }
      },
      "id": "a2000000-0000-4000-8000-000000000003",
      "name": "Get Contact Details",
      "type": "n8n-nodes-datagleaner.dataGleaner",
      "typeVersion": 1,
      "position": [
        600,
        0
      ],
      "credentials": {
        "dataGleanerApi": {
          "id": "",
          "name": "Data Gleaner (Apify) API"
        }
      },
      "onError": "continueRegularOutput",
      "notesInFlow": true,
      "notes": "Runs once per place with a company website (social-network pages are filtered out by the node before it). A site that fails passes through empty instead of stopping the workflow."
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "placeId": "={{ $('Find Local Leads').item.json.placeId }}",
            "name": "={{ $('Find Local Leads').item.json.name }}",
            "address": "={{ $('Find Local Leads').item.json.address }}",
            "phone": "={{ $('Find Local Leads').item.json.phone }}",
            "website": "={{ $('Find Local Leads').item.json.website }}",
            "emails": "={{ ($json.emailList || []).join(', ') }}",
            "linkedin": "={{ ($json.linkedin || []).join(', ') }}",
            "facebook": "={{ ($json.facebook || []).join(', ') }}"
          },
          "matchingColumns": [
            "placeId"
          ],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {}
      },
      "id": "a2000000-0000-4000-8000-000000000004",
      "name": "Write to Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        840,
        0
      ],
      "notesInFlow": true,
      "notes": "Pick your spreadsheet and tab. Row 1 needs the headers: placeId, name, address, phone, website, emails, linkedin, facebook. Rows match on placeId, so reruns update instead of duplicating."
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Find Local Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Find Local Leads": {
      "main": [
        [
          {
            "node": "Company Website?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Contact Details": {
      "main": [
        [
          {
            "node": "Write to Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Company Website?": {
      "main": [
        [
          {
            "node": "Get Contact Details",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Write to Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  }
}
