{
  "id": "ug9yvyLsKpTuerra",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Template Google Maps Scraper via Apify in Google Sheets",
  "tags": [],
  "nodes": [
    {
      "id": "144c8ee1-7ea5-4adc-ab30-374f975e911c",
      "name": "Append row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        464,
        544
      ],
      "parameters": {
        "columns": {
          "value": {
            "City": "={{ $json.city }}",
            "Phone": "={{(() => {\n  const raw = $json.phone; // vervang \"phone\" door het juiste veldnaam\n  const digits = raw.replace(/\\s+/g, ''); // verwijdert spaties\n  if (digits.startsWith('+31')) {\n    return '0' + digits.slice(3); // vervang +31 door 0\n  }\n  return digits;\n})()}}\n",
            "Title": "={{ $json.title }}",
            "Street": "={{ $json.street }}",
            "Website": "={{ $json.website }}",
            "Postcode": "={{ $json.postalCode }}"
          },
          "schema": [
            {
              "id": "Title",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Street",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Street",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Postcode",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Postcode",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "City",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "City",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Website",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{YOUR_TAB_NAME}}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{YOUR_SPREADSHEET_ID}}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "00556def-df1a-4e1b-9e0d-0a7862ca4234",
      "name": "Run task",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        -432,
        544
      ],
      "parameters": {
        "resource": "Actor tasks",
        "operation": "Run task",
        "actorTaskId": {
          "__rl": true,
          "mode": "id",
          "value": "={{YOUR_APIFY_TASK_ID}}"
        },
        "waitForFinish": 10
      },
      "credentials": {
        "apifyApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e37c1706-912c-4759-a679-7561f0de84eb",
      "name": "Get dataset items",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        240,
        544
      ],
      "parameters": {
        "resource": "Datasets",
        "datasetId": "={{ $json.defaultDatasetId }}",
        "operation": "Get items"
      },
      "credentials": {
        "apifyApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f12daca5-492c-456a-8730-675c7bde0ac2",
      "name": "Get last run",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        16,
        544
      ],
      "parameters": {
        "actorId": {
          "__rl": true,
          "mode": "id",
          "value": "{{YOUR_ACTOR_ID}}"
        },
        "operation": "Get last run"
      },
      "credentials": {
        "apifyApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "54151400-6732-4a68-b804-cd6390ec2d78",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        -208,
        544
      ],
      "parameters": {
        "amount": 60
      },
      "typeVersion": 1.1
    },
    {
      "id": "20f7ac73-ea65-448b-a566-7bc9349cc9e2",
      "name": "Start workflow",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -656,
        544
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "7a74069c-1724-429b-8db6-e91ed60c1a78",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -432
      ],
      "parameters": {
        "width": 1344,
        "height": 928,
        "content": "## Get leads from Google Maps with Apify updated in your Google Sheets\n## Who's it for\nThis workflow is ideal for marketers, sales professionals, and solo entrepreneurs who want to collect local leads based on Google Maps search terms \u2014 for example, restaurants in North Holland.\n\n## What it does\nThis workflow uses an Apify actor to scrape business details from Google Maps and automatically appends them to a Google Sheet with the following fields:\n\n- Business name\n- Street\n- Postal code\n- City\n- Website\n- Phone number\n\n## How it works\n1. The workflow starts with a manual trigger (you can replace it with any other trigger).\n2. The Google Maps Scraper Apify actor is launched.\n3. A short wait ensures the actor completes the task (you can increase the wait time for more extensive outputs).\n4. The resulting dataset is retrieved from Apify.\n5. Data is mapped and added into a connected Google Sheet.\n\n## How to set up\nStep 1: Configure the \u201cRun Apify scraper\u201d node\nGo to the Google Maps Scraper actor on Apify.\nCreate a new Task with your search term.\nFind your actor from list.\n\nStep 2: Edit the \u201cFind your last run\u201d node\nSelect the correct actor (Google Maps Scraper) from the dropdown in this node.\n\nStep 3: Fetch the dataset\nIn the \u201cGet the data from Apify\u201d node, use {{$json.defaultDatasetId}} to dynamically pull the correct dataset.\n\nStep 4: Connect your Google Sheet\nLink your Google account and select the desired spreadsheet and tab (for example, Leads).\nMake sure the column headers match the data fields.\n\nCurrent column headers:\nTitle\tStreet\tPostcode\tCity\tWebsite\tPhone"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "69b9df9b-8646-4ba7-b5fc-cd9b27d3543a",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Get last run",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run task": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get last run": {
      "main": [
        [
          {
            "node": "Get dataset items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start workflow": {
      "main": [
        [
          {
            "node": "Run task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get dataset items": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        []
      ]
    }
  }
}