{
  "name": "Add new Google Maps businesses to Google Sheets every week with Maps Harvest",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 8
            }
          ]
        }
      },
      "id": "7a1c2b63-3f6e-4b9f-8b54-1d2e3f4a5b01",
      "name": "Every Monday at 8:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        300
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a1",
              "name": "query",
              "value": "Restaurant",
              "type": "string"
            },
            {
              "id": "a2",
              "name": "country",
              "value": "us",
              "type": "string"
            },
            {
              "id": "a3",
              "name": "states",
              "value": "Florida",
              "type": "string"
            },
            {
              "id": "a4",
              "name": "cities",
              "value": "Miami",
              "type": "string"
            },
            {
              "id": "a5",
              "name": "max_total_results",
              "value": 100,
              "type": "number"
            },
            {
              "id": "a6",
              "name": "require_phone",
              "value": true,
              "type": "boolean"
            },
            {
              "id": "a7",
              "name": "min_rating",
              "value": 0,
              "type": "number"
            }
          ]
        },
        "options": {}
      },
      "id": "7a1c2b63-3f6e-4b9f-8b54-1d2e3f4a5b02",
      "name": "Your search",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        220,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.mapsharvest.com/scrape",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ query: $json.query, country: $json.country, states: $json.states, cities: $json.cities || undefined, max_total_results: $json.max_total_results, require_phone: $json.require_phone, min_rating: $json.min_rating || undefined, name: 'n8n: ' + $json.query + ' in ' + ($json.cities || $json.states) }) }}",
        "options": {}
      },
      "id": "7a1c2b63-3f6e-4b9f-8b54-1d2e3f4a5b03",
      "name": "Start the search",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        300
      ]
    },
    {
      "parameters": {
        "amount": 30
      },
      "id": "7a1c2b63-3f6e-4b9f-8b54-1d2e3f4a5b04",
      "name": "Wait 30 seconds",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        660,
        300
      ],
      "webhookId": "0d7c5f4e-3a1b-4c2d-9e8f-7a6b5c4d3e21"
    },
    {
      "parameters": {
        "url": "=https://api.mapsharvest.com/jobs/{{ $('Start the search').first().json.job_id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "id": "7a1c2b63-3f6e-4b9f-8b54-1d2e3f4a5b05",
      "name": "Check progress",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        300
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "c1",
                    "leftValue": "={{ ['completed', 'stopped'].includes($json.status) }}",
                    "rightValue": true,
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Finished"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict"
                },
                "conditions": [
                  {
                    "id": "c2",
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "failed",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Failed"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "Still running"
        }
      },
      "id": "7a1c2b63-3f6e-4b9f-8b54-1d2e3f4a5b06",
      "name": "Finished?",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        1100,
        300
      ]
    },
    {
      "parameters": {
        "url": "=https://api.mapsharvest.com/jobs/{{ $('Start the search').first().json.job_id }}/download?fmt=csv",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "7a1c2b63-3f6e-4b9f-8b54-1d2e3f4a5b07",
      "name": "Download the leads",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1340,
        160
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "7a1c2b63-3f6e-4b9f-8b54-1d2e3f4a5b08",
      "name": "Read the CSV",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        1560,
        160
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list",
          "cachedResultName": ""
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": []
        },
        "options": {}
      },
      "id": "7a1c2b63-3f6e-4b9f-8b54-1d2e3f4a5b09",
      "name": "Add new ones to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1780,
        160
      ]
    },
    {
      "parameters": {
        "errorMessage": "={{ 'The Maps Harvest search failed: ' + ($json.error || 'no reason given') }}"
      },
      "id": "7a1c2b63-3f6e-4b9f-8b54-1d2e3f4a5b10",
      "name": "Stop: search failed",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        1340,
        320
      ]
    },
    {
      "parameters": {
        "content": "## New businesses on Google Maps, every week\n\nEvery Monday, searches Google Maps for one kind of business in one place with **Maps Harvest** and adds the businesses that are new to you to your Google Sheet. Good for spotting new restaurants, clinics or shops to pitch before anyone else does.\n\nMaps Harvest never gives your account the same business twice, so after the first run each week brings only listings you have not had before, and you only pay for those.\n\n### Set up (5 minutes)\n1. Get an API key: sign up at [mapsharvest.com](https://www.mapsharvest.com/signup?utm_source=n8n&utm_medium=template&utm_campaign=weekly), then **Dashboard → Integrations → API access**.\n2. Create a **Header Auth** credential: Name `Authorization`, Value `Bearer mh_live_...` (your key). Pick it in the three Maps Harvest HTTP nodes.\n3. Edit **Your search**: business type, country (`us`, `uk`, `canada`, `australia`, `germany`, `india`), state or region, city, and the most new leads to take each week.\n4. Connect Google Sheets and pick your spreadsheet in **Add new ones to Google Sheets**. Use an empty sheet.\n5. Run it once by hand to fill the sheet, then switch the workflow to **Active**.\n\nEach new lead uses one credit. API docs: [mapsharvest.com/docs](https://www.mapsharvest.com/docs)",
        "height": 600,
        "width": 420
      },
      "id": "7a1c2b63-3f6e-4b9f-8b54-1d2e3f4a5b11",
      "name": "Read me",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -480,
        100
      ]
    },
    {
      "parameters": {
        "content": "Checks every 30 seconds until the search is done, however long it takes.",
        "height": 120,
        "width": 440,
        "color": 7
      },
      "id": "7a1c2b63-3f6e-4b9f-8b54-1d2e3f4a5b12",
      "name": "Note: waiting",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        640,
        460
      ]
    }
  ],
  "connections": {
    "Every Monday at 8:00": {
      "main": [
        [
          {
            "node": "Your search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Your search": {
      "main": [
        [
          {
            "node": "Start the search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start the search": {
      "main": [
        [
          {
            "node": "Wait 30 seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 30 seconds": {
      "main": [
        [
          {
            "node": "Check progress",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check progress": {
      "main": [
        [
          {
            "node": "Finished?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Finished?": {
      "main": [
        [
          {
            "node": "Download the leads",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop: search failed",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 30 seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download the leads": {
      "main": [
        [
          {
            "node": "Read the CSV",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read the CSV": {
      "main": [
        [
          {
            "node": "Add new ones to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "pinData": {}
}