{
  "name": "Google Maps Lead Scraper with Apify",
  "nodes": [
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/acts/compass~crawler-google-places/runs",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n    \"includeWebResults\": false,\n    \"language\": \"en\",\n    \"locationQuery\": \"{{ $json.Location }}\",\n    \"maxCrawledPlacesPerSearch\": {{ $json[\"Number of Leads\"] }},\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.Industry }}\"\n    ],\n    \"skipClosedPlaces\": false\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -40,
        -180
      ],
      "id": "bfd802a5-39f7-470c-bf55-178d70174454",
      "name": "Scrape Google (APIFY)",
      "credentials": {
        "httpBasicAuth": {
          "id": "O0OOt4m5Ck2YFP46",
          "name": "Apify API"
        },
        "httpHeaderAuth": {
          "id": "nCVw9Gdz7a5BEsks",
          "name": "APIFY Token"
        }
      }
    },
    {
      "parameters": {
        "amount": 20,
        "unit": "seconds"
      },
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1,
      "position": [
        160,
        -180
      ],
      "id": "68876043-dc5d-4f89-8202-aaeb5a338de2",
      "webhookId": "23bd9645-94ea-47c1-88af-5b2a44c32838"
    },
    {
      "parameters": {
        "formTitle": "Lead Scraper",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Industry"
            },
            {
              "fieldLabel": "Location"
            },
            {
              "fieldLabel": "Number of Leads"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.2,
      "position": [
        -260,
        -180
      ],
      "id": "62487948-1117-49be-be2c-0058af6a511a",
      "name": "On form submission",
      "webhookId": "bed888f5-f9d6-452e-a09f-1f81ec705ca2"
    },
    {
      "parameters": {
        "url": "={{ \"https://api.apify.com/v2/datasets/\" + $json.data.defaultDatasetId + \"/items\" }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -140,
        40
      ],
      "id": "5b95cb93-f8f0-46ef-9a87-5d3d78ab56ae",
      "name": "Get Lead Data",
      "credentials": {
        "httpHeaderAuth": {
          "id": "nCVw9Gdz7a5BEsks",
          "name": "APIFY Token"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "1s9oaGi7gj0Wk1NdP0ywxxSx64fab4bq0toYMpZiMT24",
          "mode": "list",
          "cachedResultName": "apify demo",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1s9oaGi7gj0Wk1NdP0ywxxSx64fab4bq0toYMpZiMT24/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "leads",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1s9oaGi7gj0Wk1NdP0ywxxSx64fab4bq0toYMpZiMT24/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Name": "={{ $json.title }}",
            "Industry": "={{ $json.categoryName }}",
            "Address": "={{ $json.address }}",
            "Phone": "={{ $json.phone }}",
            "Website": "={{ $json.website }}",
            "Search": "={{ $json.searchString }}",
            "City": "={{ $json.city }}",
            "State": "={{ $json.state }}",
            "Country": "={{ $json.countryCode }}"
          },
          "matchingColumns": [
            "Website"
          ],
          "schema": [
            {
              "id": "Name",
              "displayName": "Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Industry",
              "displayName": "Industry",
              "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": false
            },
            {
              "id": "Website",
              "displayName": "Website",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Address",
              "displayName": "Address",
              "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,
              "removed": false
            },
            {
              "id": "State",
              "displayName": "State",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Country",
              "displayName": "Country",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Search",
              "displayName": "Search",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        80,
        40
      ],
      "id": "1050126b-9ef0-4234-b759-c9ec92db1ad2",
      "name": "Upsert Google Sheets",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "ESD8JJHqd8A9NlNx",
          "name": "Google Sheets account (Kris)"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Get Lead Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Google (APIFY)": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Scrape Google (APIFY)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Lead Data": {
      "main": [
        [
          {
            "node": "Upsert Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "01daa725-a13a-4851-a932-6d10f8875bd2",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "4aabc0aa2e160dafa4f9d9bcedde563b5af29598cd16960f637ae2fb99aea720"
  },
  "id": "PzhNqzOdtbtJArP1",
  "tags": []
}