{
  "id": "SzH05B85Poq3IPej",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Discover local business leads and run automated cold email sequences with Google Maps and Gmail",
  "tags": [],
  "nodes": [
    {
      "id": "610f4b5e-b883-49e1-a89f-3038c710a118",
      "name": "Stop and Error1",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        3408,
        2688
      ],
      "parameters": {
        "errorMessage": "Google Sheets API Limit has been triggered and the workflow has stopped"
      },
      "typeVersion": 1
    },
    {
      "id": "7a36b46c-dd48-431d-8b09-161da8d69b28",
      "name": "Update Status to Success",
      "type": "n8n-nodes-base.googleSheets",
      "onError": "continueErrorOutput",
      "position": [
        2608,
        3120
      ],
      "parameters": {
        "columns": {
          "value": {
            "Zip": "={{ $json.Zip }}",
            "status": "scraped"
          },
          "schema": [
            {
              "id": "Zip",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Zip",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Zip"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Settings').first().json.sheet }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $('Settings').first().json.gs_url }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "executeOnce": true,
      "typeVersion": 4.2,
      "alwaysOutputData": true
    },
    {
      "id": "488670dd-498f-486c-9a57-23403095188c",
      "name": "Stop and Error",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        3408,
        3120
      ],
      "parameters": {
        "errorMessage": "Google Sheets API Limit has been triggered and the workflow has stopped"
      },
      "typeVersion": 1
    },
    {
      "id": "45a95e8c-f478-4ace-816c-f6d3f05f6847",
      "name": "Stop and Error2",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        3408,
        2896
      ],
      "parameters": {
        "errorMessage": "Google Sheets API Limit has been triggered and the workflow has stopped"
      },
      "typeVersion": 1
    },
    {
      "id": "4fe4e969-57ac-4f43-9b77-8ec757db5438",
      "name": "Get Status",
      "type": "n8n-nodes-base.googleSheets",
      "onError": "continueErrorOutput",
      "position": [
        2608,
        2896
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $('Set Zip1').item.json.Zip }}",
              "lookupColumn": "Zip"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Settings').first().json.sheet }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $('Settings').first().json.gs_url }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "executeOnce": true,
      "typeVersion": 4.2
    },
    {
      "id": "839f3d83-1354-477e-b149-034069c9143e",
      "name": "Get row(s) in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -464,
        3600
      ],
      "parameters": {
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "your-gsheet-id"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "7b43b639-4cce-4289-b718-cc0f7789741f",
      "name": "Update row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        656,
        3600
      ],
      "parameters": {
        "columns": {
          "value": {
            "intro mail": "={{ JSON.parse($json.content.parts[0].text).intro_mail }}",
            "row_number": "={{ $('Loop: Generate AI Emails').item.json.row_number }}",
            "follow up mail 1": "={{ JSON.parse($json.content.parts[0].text).follow_up_mail_1 }}",
            "follow up mail 2": "={{ JSON.parse($json.content.parts[0].text).follow_up_mail_2 }}"
          },
          "schema": [
            {
              "id": "place_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "place_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "phone",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "rating",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "rating",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reviews",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "reviews",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "type",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intro mail",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "intro mail",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email_status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "email_status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intro_email_sent_date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "intro_email_sent_date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 1",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up email send date 1",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up email send date 1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 1 status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 1 status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 2",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up email send date 2",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up email send date 2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 2 status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 2 status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "types",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "types",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1495216019,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nY4Os8IsdEmNW4W-MkLtnN05EMgLYyoaS2-BPoJ_Iu4/edit#gid=1495216019",
          "cachedResultName": "Results"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1nY4Os8IsdEmNW4W-MkLtnN05EMgLYyoaS2-BPoJ_Iu4",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nY4Os8IsdEmNW4W-MkLtnN05EMgLYyoaS2-BPoJ_Iu4/edit?usp=drivesdk",
          "cachedResultName": "Google Maps Scraper Setup File"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "52ce659b-e0aa-46cf-b654-023b85ea807a",
      "name": "Get row(s) in sheet1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1568,
        3552
      ],
      "parameters": {
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "your-gsheet-id"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "7cc03b90-133d-4ca2-937f-12295eef351d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -944,
        3504
      ],
      "parameters": {
        "width": 1920,
        "height": 320,
        "content": "## Email Writer (Intro + Follow Up 1 + Follow Up 2)"
      },
      "typeVersion": 1
    },
    {
      "id": "913f34f4-1f97-4720-afac-c1a41a0ac9a1",
      "name": "Get row(s) in sheet4",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3520,
        3584
      ],
      "parameters": {
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "your-gsheet-id"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "2e1717d7-4e10-4db5-8a36-70d416e556f8",
      "name": "Get row(s) in sheet5",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1520,
        4112
      ],
      "parameters": {
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "your-sheet-id"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "3b83eafc-ebaf-49cd-aaa3-d965d124b45c",
      "name": "Update row in sheet3",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2736,
        4112
      ],
      "parameters": {
        "columns": {
          "value": {
            "row_number": "={{ $('Loop: Send Follow Up 2').item.json.row_number }}",
            "follow up mail 2 id": "={{ $json.id }}",
            "follow up mail 2 status": "yes"
          },
          "schema": [
            {
              "id": "place_id",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "place_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "phone",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "website",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "rating",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "rating",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reviews",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "reviews",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "type",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intro mail",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "intro mail",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intro mail id",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "intro mail id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email_status",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "email_status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intro_email_sent_date",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "intro_email_sent_date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 1",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "follow up mail 1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 1 id",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "follow up mail 1 id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up email send date 1",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "follow up email send date 1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 1 status",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "follow up mail 1 status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 2",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "follow up mail 2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 2 id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 2 id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up email send date 2",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "follow up email send date 2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 2 status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 2 status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "types",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "types",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1495216019,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nY4Os8IsdEmNW4W-MkLtnN05EMgLYyoaS2-BPoJ_Iu4/edit#gid=1495216019",
          "cachedResultName": "Results"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1nY4Os8IsdEmNW4W-MkLtnN05EMgLYyoaS2-BPoJ_Iu4",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nY4Os8IsdEmNW4W-MkLtnN05EMgLYyoaS2-BPoJ_Iu4/edit?usp=drivesdk",
          "cachedResultName": "Google Maps Scraper Setup File"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "f07823fd-fd84-425f-98b9-17a0f889dd28",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1072,
        3472
      ],
      "parameters": {
        "width": 1904,
        "height": 352,
        "content": "## Intro Mail Send"
      },
      "typeVersion": 1
    },
    {
      "id": "23dbb356-8889-489b-a3aa-70a0c96c3ffd",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3056,
        3488
      ],
      "parameters": {
        "width": 1904,
        "height": 336,
        "content": "## Follow Up 1 Mail Send"
      },
      "typeVersion": 1
    },
    {
      "id": "05bb4778-419b-4c41-8ae5-f6f9950e8d32",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1072,
        4000
      ],
      "parameters": {
        "width": 1904,
        "height": 336,
        "content": "## Follow Up 2 Mail Send"
      },
      "typeVersion": 1
    },
    {
      "id": "c8443840-3fbe-4823-8d54-a3987ad6e5ea",
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "position": [
        864,
        2384
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "fa469a25-eb00-4011-a626-87fae7fb8bbd",
              "name": "gs_url",
              "type": "string",
              "value": "<ypur-google-sheets-link>"
            },
            {
              "id": "df0a7a51-0ec6-47d2-9f73-bc8268385305",
              "name": "catSheet",
              "type": "string",
              "value": "Google Maps Categories"
            },
            {
              "id": "a1ff9a58-9ae6-4000-9fcd-6c11de23bd48",
              "name": "sheet",
              "type": "string",
              "value": "Zips"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "30947e7d-836e-4ebf-820e-4b181ebc814f",
      "name": "Get Zip Codes",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1056,
        2384
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Settings').item.json.sheet }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $('Settings').item.json.gs_url }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "executeOnce": true,
      "typeVersion": 4.2
    },
    {
      "id": "fdb0dce3-2873-4221-8d7a-12bdb9023cc9",
      "name": "Zips",
      "type": "n8n-nodes-base.set",
      "position": [
        1264,
        2384
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "3d16d922-0ed3-4a0f-9707-43797438970d",
              "name": "zip",
              "type": "string",
              "value": "={{ $json.Zip }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "4a5a8a75-1e28-419f-aa57-9877dcbcfac9",
      "name": "Filter Zips",
      "type": "n8n-nodes-base.filter",
      "position": [
        1456,
        2384
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9f5a5e37-faae-45db-8a22-ad7d5786ecfe",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": ""
            },
            {
              "id": "0e38f9fa-c3f1-49c3-ad71-8dffc2555333",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "7ecc5210-4ff7-453c-ae17-93f976ddd9ba",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1648,
        2384
      ],
      "parameters": {
        "include": "allOtherFields",
        "options": {},
        "fieldToSplitOut": "row_number"
      },
      "typeVersion": 1
    },
    {
      "id": "902d0aca-bd6c-49c1-8578-134d90236116",
      "name": "Get Category",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2128,
        2496
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('Settings').item.json.catSheet }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $('Settings').item.json.gs_url }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "executeOnce": true,
      "typeVersion": 4.2
    },
    {
      "id": "30ae9253-1a34-49bf-8c20-94f49e4766d9",
      "name": "Set Zip",
      "type": "n8n-nodes-base.set",
      "position": [
        2736,
        2416
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f6442dd8-5638-4a18-8d1d-9a3a09398103",
              "name": "Zip",
              "type": "string",
              "value": "={{ $json.Zip }}"
            },
            {
              "id": "3a637f53-9f44-4f9d-8d6d-1338458df114",
              "name": "Category",
              "type": "string",
              "value": "={{ $json.Category }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "2e336d7b-5001-459b-8dd8-d425e448c616",
      "name": "Loop Subcats",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        704,
        2944
      ],
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "typeVersion": 3
    },
    {
      "id": "595ac616-6b61-4410-af61-7c29e26050ea",
      "name": "Set Zip1",
      "type": "n8n-nodes-base.set",
      "position": [
        880,
        2944
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "7b1629c5-cbfe-4769-8286-66b46c51cd7e",
              "name": "Zip",
              "type": "string",
              "value": "={{ $('Set Zip').item.json.Zip }}"
            },
            {
              "id": "9414efa6-bf07-480a-aec2-3f35a315bf2b",
              "name": "Category",
              "type": "string",
              "value": "={{ $json.Category }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "97767fb6-1a01-492d-aade-e4e9b626b64b",
      "name": "GMaps API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1088,
        2944
      ],
      "parameters": {
        "url": "https://places.googleapis.com/v1/places:searchText?key=YOUR_TOKEN_HERE",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        },
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "textQuery",
              "value": "={{ $json.Category }} {{ $json.Zip }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Goog-FieldMask",
              "value": "*"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "fdfe9ea7-1c9a-49c6-b43a-5c2d3f684ca0",
      "name": "Scrape URL",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        1680,
        2944
      ],
      "parameters": {
        "url": "={{ $json.websiteUri }}",
        "options": {
          "response": {
            "response": {
              "neverError": true
            }
          },
          "allowUnauthorizedCerts": true
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0 Safari/537.36"
            },
            {
              "name": "Accept",
              "value": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
            },
            {
              "name": "Accept-Language",
              "value": "en-US,en;q=0.9"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.3
    },
    {
      "id": "1784f246-0b31-4270-a4f4-c9a2855163a4",
      "name": "Add rows in Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "onError": "continueErrorOutput",
      "position": [
        2608,
        2688
      ],
      "parameters": {
        "columns": {
          "value": {
            "type": "={{ $('Set Zip1').item.json.Category }}",
            "email": "={{ $json.email }}",
            "phone": "={{ $json.place.nationalPhoneNumber }}",
            "title": "={{ $json.place.displayName.text }}",
            "types": "={{ $json.place.types.join(', ') }}",
            "rating": "={{ $json.place.rating }}",
            "address": "={{ $json.place.formattedAddress }}",
            "reviews": "={{ $json.place.userRatingCount }}",
            "website": "={{ $json.place.websiteUri }}",
            "place_id": "={{ $json.place.id }}"
          },
          "schema": [
            {
              "id": "place_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "place_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "phone",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "website",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "rating",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "rating",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reviews",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "reviews",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intro mail",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "intro mail",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "types",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "types",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "place_id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "=Results"
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $('Settings').first().json.gs_url }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": true
    },
    {
      "id": "6311bb94-4b95-420b-9a58-ab51bb2c9cf7",
      "name": "Email Writer",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        336,
        3600
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.0-flash-lite",
          "cachedResultName": "models/gemini-2.0-flash-lite"
        },
        "options": {
          "systemMessage": "=You are a senior B2B sales copywriter.\nYou generate high-performing cold outreach email copy.\nYou must follow instructions strictly."
        },
        "messages": {
          "values": [
            {
              "content": "=Generate a JSON object with 3 fields:\n- intro_mail\n- follow_up_mail_1\n- follow_up_mail_2\n\nEach field must contain a complete cold outreach email content.\n\nInputs:\n- Recipient title: {{ $json.title }}\n- Business type: {{ $json.type }}\n- Google Maps categories: {{ $json.types }}\n\nOur company:\nYOUR COMPANY NAME\n\nOur services:\n- Digital marketing\n- SEO\n- Website development\n- Automation (n8n)\n- AI-powered workflows\n- Business process optimization\n\nRules for EACH email:\n- Start with a friendly greeting using the business type or title (example: \"Hi there,\" or \"Hi {{ $json.title }},\").\n- DO NOT include any signature or closing.\n- DO NOT repeat the business name more than once.\n- Use <br><br> for line breaks.\n- No other HTML.\n- 4 to 5 short sentences.\n- Friendly, professional, human tone.\n- Mention automation or AI at least once.\n- End with a soft value-based statement (not a meeting request).\n\nAdditional sequencing rules:\n- intro_mail: general introduction and value.\n- follow_up_mail_1: gentle nudge, assume they saw the first email.\n- follow_up_mail_2: final follow-up, slightly more direct but still polite.\n\nOutput format:\nReturn ONLY valid JSON.\nNo explanations.\nNo extra text.\n"
            }
          ]
        },
        "jsonOutput": true,
        "builtInTools": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "56cdb48b-1ed4-4f8d-97a5-9d96832740f0",
      "name": "Send Intro Mail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2320,
        3552
      ],
      "parameters": {
        "sendTo": "={{ $json['email'] }}",
        "message": "=<!DOCTYPE html>\n<html>\n  <body style=\"margin:0;padding:0;background-color:#f6f8fa;font-family:Arial, Helvetica, sans-serif;\">\n    <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#f6f8fa;padding:20px 0;\">\n      <tr>\n        <td align=\"center\">\n          <table width=\"600\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#ffffff;border-radius:8px;box-shadow:0 2px 8px rgba(0,0,0,0.05);padding:30px;\">\n            \n            <!-- Logo -->\n            <tr>\n              <td align=\"center\" style=\"padding-bottom:20px;\">\n                <img \n                  src=\"your-company-logo-link-public\" \n                  alt=\"company name\" \n                  width=\"160\"\n                  style=\"display:block;border:0;outline:none;text-decoration:none;\"\n                />\n              </td>\n            </tr>\n          \n            <!-- Dynamic Body -->\n            <tr>\n              <td style=\"font-size:14px;color:#374151;line-height:1.7;\">\n                {{ $json['intro mail'] }}\n              </td>\n            </tr>\n\n            <!-- CTA -->\n            <tr>\n              <td style=\"padding-top:18px;font-size:14px;color:#374151;\">\n                YOUR CTA\n              </td>\n            </tr>\n\n            <!-- Signature -->\n            <tr>\n              <td style=\"padding-top:28px;font-size:14px;color:#111827;\">\n                Regards,<br>\n                <strong>Founder Name</strong><br>\n                <span style=\"color:#6b7280;\">your-company-name</span>\n              </td>\n            </tr>\n\n            <!-- Footer -->\n            <tr>\n              <td style=\"padding-top:20px;font-size:11px;color:#9ca3af;\">\n                Automation \u2022 AI \u2022 Data Engineering \u2022 Workflow Optimization\n              </td>\n            </tr>\n\n          </table>\n        </td>\n      </tr>\n    </table>\n  </body>\n</html>",
        "options": {
          "senderName": "Your Company Name or Founder Name ",
          "appendAttribution": false,
          "replyToSenderOnly": true
        },
        "subject": "=Reducing manual work at {{ $json.title }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f2d5bc92-f7ec-4b8e-b1b3-4bad71ac2399",
      "name": "Update Row with all Follow Up Mail Dates",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2720,
        3552
      ],
      "parameters": {
        "columns": {
          "value": {
            "row_number": "={{ $('Loop: Send Intro Emails').item.json.row_number }}",
            "email_status": "={{ $json.intro_sent }}",
            "intro mail id": "={{ $json.id }}",
            "intro_email_sent_date": "={{ $json.intro_date }}",
            "follow up mail 1 status": "={{ $json.fu1_sent }}",
            "follow up mail 2 status": "={{ $json.fu2_sent }}",
            "follow up email send date 1": "={{ $json.fu1_date }}",
            "follow up email send date 2": "={{ $json.fu2_date }}"
          },
          "schema": [
            {
              "id": "place_id",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "place_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "phone",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "website",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "rating",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "rating",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reviews",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "reviews",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "type",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intro mail",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "intro mail",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intro mail id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "intro mail id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email_status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "email_status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intro_email_sent_date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "intro_email_sent_date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 1",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 1 id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 1 id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up email send date 1",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up email send date 1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 1 status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 1 status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 2",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 2 id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 2 id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up email send date 2",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up email send date 2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 2 status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 2 status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "types",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "types",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1495216019,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nY4Os8IsdEmNW4W-MkLtnN05EMgLYyoaS2-BPoJ_Iu4/edit#gid=1495216019",
          "cachedResultName": "Results"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1nY4Os8IsdEmNW4W-MkLtnN05EMgLYyoaS2-BPoJ_Iu4",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nY4Os8IsdEmNW4W-MkLtnN05EMgLYyoaS2-BPoJ_Iu4/edit?usp=drivesdk",
          "cachedResultName": "Google Maps Scraper Setup File"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "e40cca03-2199-442b-8cc1-fb3e7d08364c",
      "name": "Update row with follow up status 1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        4720,
        3584
      ],
      "parameters": {
        "columns": {
          "value": {
            "row_number": "={{ $('Loop: Send Follow Up 1').item.json.row_number }}",
            "follow up mail 1 id": "={{ $json.id }}",
            "follow up mail 1 status": "=yes"
          },
          "schema": [
            {
              "id": "place_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "place_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "phone",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "rating",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "rating",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reviews",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "reviews",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "type",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intro mail",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "intro mail",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intro mail id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "intro mail id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email_status",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "email_status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "intro_email_sent_date",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "intro_email_sent_date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 1",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 1 id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 1 id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up email send date 1",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "follow up email send date 1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 1 status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 1 status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 2",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 2 id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "follow up mail 2 id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up email send date 2",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "follow up email send date 2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "follow up mail 2 status",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "follow up mail 2 status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "types",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "types",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1495216019,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nY4Os8IsdEmNW4W-MkLtnN05EMgLYyoaS2-BPoJ_Iu4/edit#gid=1495216019",
          "cachedResultName": "Results"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1nY4Os8IsdEmNW4W-MkLtnN05EMgLYyoaS2-BPoJ_Iu4",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1nY4Os8IsdEmNW4W-MkLtnN05EMgLYyoaS2-BPoJ_Iu4/edit?usp=drivesdk",
          "cachedResultName": "Google Maps Scraper Setup File"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "f9c82f3d-873a-4899-bc1e-0e7168aabcef",
      "name": "Follow Up Mail 2",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2480,
        4112
      ],
      "parameters": {
        "message": "=<!DOCTYPE html>\n<html>\n  <body style=\"margin:0;padding:0;background-color:#f6f8fa;font-family:Arial, Helvetica, sans-serif;\">\n    <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#f6f8fa;padding:20px 0;\">\n      <tr>\n        <td align=\"center\">\n          <table width=\"600\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#ffffff;border-radius:8px;box-shadow:0 2px 8px rgba(0,0,0,0.05);padding:30px;\">\n            \n            <!-- Logo -->\n            <tr>\n              <td align=\"center\" style=\"padding-bottom:20px;\">\n                <img \n                  src=\"YOUR-COMPANY-LOGO-LINK\" \n                  alt=\"COMPANY NAme\" \n                  width=\"160\"\n                  style=\"display:block;border:0;outline:none;text-decoration:none;\"\n                />\n              </td>\n            </tr>\n          \n            <!-- Dynamic Body -->\n            <tr>\n              <td style=\"font-size:14px;color:#374151;line-height:1.7;\">\n                {{ $json['follow up mail 2'] }}\n              </td>\n            </tr>\n\n            <!-- CTA -->\n            <tr>\n              <td style=\"padding-top:18px;font-size:14px;color:#374151;\">\n                your cta\n              </td>\n            </tr>\n\n            <!-- Signature -->\n            <tr>\n              <td style=\"padding-top:28px;font-size:14px;color:#111827;\">\n                Regards,<br>\n                <strong>FOUNDER NAME</strong><br>\n                <span style=\"color:#6b7280;\">COMPANY NAme</span>\n              </td>\n            </tr>\n\n            <!-- Footer -->\n            <tr>\n              <td style=\"padding-top:20px;font-size:11px;color:#9ca3af;\">\n                Automation \u2022 AI \u2022 Data Engineering \u2022 Workflow Optimization\n              </td>\n            </tr>\n\n          </table>\n        </td>\n      </tr>\n    </table>\n  </body>\n</html>",
        "options": {
          "senderName": "YOUR COMPANY NAME",
          "appendAttribution": false
        },
        "messageId": "={{ $json['follow up mail 1 id'] }}",
        "operation": "reply"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "7984984d-fa9a-4c58-8527-617055801a6f",
      "name": "Follow Up Mail 1",
      "type": "n8n-nodes-base.gmail",
      "position": [
        4464,
        3584
      ],
      "parameters": {
        "message": "=<!DOCTYPE html>\n<html>\n  <body style=\"margin:0;padding:0;background-color:#f6f8fa;font-family:Arial, Helvetica, sans-serif;\">\n    <table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#f6f8fa;padding:20px 0;\">\n      <tr>\n        <td align=\"center\">\n          <table width=\"600\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-color:#ffffff;border-radius:8px;box-shadow:0 2px 8px rgba(0,0,0,0.05);padding:30px;\">\n            \n            <!-- Logo -->\n            <tr>\n              <td align=\"center\" style=\"padding-bottom:20px;\">\n                <img \n                  src=\"your-company-logo-link\" \n                  alt=\"company name\" \n                  width=\"160\"\n                  style=\"display:block;border:0;outline:none;text-decoration:none;\"\n                />\n              </td>\n            </tr>\n          \n            <!-- Dynamic Body -->\n            <tr>\n              <td style=\"font-size:14px;color:#374151;line-height:1.7;\">\n                {{ $('Loop: Send Follow Up 1').item.json['follow up mail 1'] }}\n              </td>\n            </tr>\n\n            <!-- CTA -->\n            <tr>\n              <td style=\"padding-top:18px;font-size:14px;color:#374151;\">\n                YOUR CTA\n              </td>\n            </tr>\n\n            <!-- Signature -->\n            <tr>\n              <td style=\"padding-top:28px;font-size:14px;color:#111827;\">\n                Regards,<br>\n                <strong>Founder Name</strong><br>\n                <span style=\"color:#6b7280;\">YOUR COMPANY NAME</span>\n              </td>\n            </tr>\n\n            <!-- Footer -->\n            <tr>\n              <td style=\"padding-top:20px;font-size:11px;color:#9ca3af;\">\n                Automation \u2022 AI \u2022 Data Engineering \u2022 Workflow Optimization\n              </td>\n            </tr>\n\n          </table>\n        </td>\n      </tr>\n    </table>\n  </body>\n</html>",
        "options": {
          "senderName": "Your Company Name or Founder Name",
          "appendAttribution": false
        },
        "messageId": "={{ $json['intro mail id'] }}",
        "operation": "reply"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4bd71216-51ca-4564-9bad-aea0381078f3",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        2544
      ],
      "parameters": {
        "width": 704,
        "height": 560,
        "content": "## How it works\n\nThis workflow automatically finds local business leads from Google Maps, extracts contact emails from their websites, generates personalized cold emails using AI, and sends a complete 3-step outreach sequence (intro + 2 follow-ups).\n\nIt runs on a schedule, processes new locations by ZIP code and business category, stores everything in Google Sheets, and tracks which emails were sent and when. Follow-ups are triggered automatically based on dates, so no manual work is needed after setup.\n\nThe system includes retry logic, rate-limit handling, and status tracking to make it safe for long-running automation.\n\n## Setup steps\n\n1. Create a Google Sheet with tabs for ZIP codes, categories, and results or make a copy of [GSheets Link](https://docs.google.com/spreadsheets/d/1BRPF4IHoxtAIE5gBQMNP_qIux_XNDXTnmIEHYcl5kEk/edit?usp=sharing)\n2. Add your Google Maps API key.\n3. Connect Google Sheets and Gmail credentials.\n4. Replace placeholders (company name, logo, CTA).\n5. Enable schedule triggers.\n\nOnce enabled, the workflow runs fully hands-free.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5c00ca6c-f081-47f4-98db-e12265ff6894",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        2224
      ],
      "parameters": {
        "width": 3120,
        "height": 1120,
        "content": "## Lead Generation through GMaps API"
      },
      "typeVersion": 1
    },
    {
      "id": "43a2097b-4cd2-4059-8fef-f0016d758556",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3728,
        2336
      ],
      "parameters": {
        "width": 704,
        "height": 880,
        "content": "## How to run\n\n1. Go to Google Sheets and open the sheet named **Zips**.  \n   Add the locations you want to scrape, for example:  \n   - 600001  \n   - Anna Nagar, Chennai, Tamil Nadu  \n   You can add multiple rows.\n\n2. Open the sheet named **Google Maps Categories**.  \n   Add business categories you want to target, for example:  \n   - Veg restaurants  \n   - Dental clinics  \n   - Software companies  \n\n3. Run the first part of the workflow to generate leads.\n\n4. After publishing the workflow, the email writer runs automatically every minute.  \n   It fills:\n   - Intro mail  \n   - Follow-up mail 1  \n   - Follow-up mail 2  \n\n   Only for rows where **Intro mail is empty**.\n\n5. The intro mail sender runs when:\n   - Intro mail is not empty  \n   - Email status is empty  \n\n   It sends the intro email immediately.\n\n6. Follow-up logic:\n   - Follow-up 1 is sent 7 days after the intro mail.  \n   - Follow-up 2 is sent 11 days after the intro mail.  \n\n   The workflow stores message IDs to send follow-ups as replies.\n\n7. Follow-up workflows run every day at **8 AM**.  \n   They check if today is the follow-up date and send emails only when due.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "588f761d-0f99-46bc-a9b4-87107100b8be",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        2816
      ],
      "parameters": {
        "color": 2,
        "width": 400,
        "height": 320,
        "content": "## Lead discovery\n\nReads ZIP codes and business categories from Google Sheets, then queries Google Maps to find matching local businesses.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "95bd805c-fe4d-4a2e-811c-2f60a0ada235",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1616,
        2800
      ],
      "parameters": {
        "width": 400,
        "height": 304,
        "content": "## Website scraping\n\nVisits each business website and extracts public email addresses from the page content.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "26b0a005-b827-4112-a9d5-a1d0f9a72965",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2544,
        2592
      ],
      "parameters": {
        "width": 416,
        "height": 736,
        "content": "## Lead storage\nSaves cleaned lead data (name, email, phone, rating, website) into the Results sheet.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5941c7e4-b6b2-420f-a553-f4c3cd60e4cc",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        3504
      ],
      "parameters": {
        "width": 544,
        "height": 272,
        "content": "## AI email generation\nGenerates personalized intro and follow-up emails using business data and categories.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "e5320358-5f56-4c47-ab50-33f7764783b4",
      "name": "Trigger: Generate AI Emails",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -752,
        3600
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 1
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "a533433c-05db-4444-aac5-8134856f26d8",
      "name": "Trigger: Send Intro Emails",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        1280,
        3552
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 1
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "da1371dd-8c12-4579-a047-012fdc2c361b",
      "name": "Trigger: Send Follow Up 1",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        3232,
        3584
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "6462fbc9-34ac-4f75-99d0-a97929667d9a",
      "name": "Trigger: Send Follow Up 2",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        1248,
        4112
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0afa0e56-6e7a-40fe-9944-14a24a59c502",
      "name": "Trigger: Lead Scraping (GMaps)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        656,
        2384
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 15
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "14117d9c-8a3a-4785-bd56-22d47afe4f12",
      "name": "Check: Intro Mail Empty",
      "type": "n8n-nodes-base.if",
      "position": [
        -208,
        3600
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "45c6ef69-6791-4af3-ab12-d3219419b700",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json[\"intro mail\"] }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "99a547b1-7a37-4afc-9e64-6f0c578f49c3",
      "name": "Check: Intro Ready & Not Sent",
      "type": "n8n-nodes-base.if",
      "position": [
        1776,
        3552
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "45c6ef69-6791-4af3-ab12-d3219419b700",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json[\"intro mail\"] }}",
              "rightValue": ""
            },
            {
              "id": "0a3ff222-8e5e-4067-91b2-17b6816be737",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json.email_status }}",
              "rightValue": "sent"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "77cbd659-1045-4b6a-858b-ab16c9c24605",
      "name": "Check: Follow Up 1 Due",
      "type": "n8n-nodes-base.if",
      "position": [
        3728,
        3584
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "45c6ef69-6791-4af3-ab12-d3219419b700",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json['follow up mail 1'] }}",
              "rightValue": ""
            },
            {
              "id": "0a3ff222-8e5e-4067-91b2-17b6816be737",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json['follow up mail 1 status'] }}",
              "rightValue": "no"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "5d1e1dfd-8f4f-480d-8b38-96d9efb3e513",
      "name": "Check: Follow Up 2 Due",
      "type": "n8n-nodes-base.if",
      "position": [
        1744,
        4112
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "45c6ef69-6791-4af3-ab12-d3219419b700",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json[\"follow up mail 2\"] }}",
              "rightValue": ""
            },
            {
              "id": "0a3ff222-8e5e-4067-91b2-17b6816be737",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json[\"follow up mail 2 status\"] }}",
              "rightValue": "no"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "def66968-912d-4625-9f31-4d0f7f41cab7",
      "name": "Check: GMaps Result Empty",
      "type": "n8n-nodes-base.if",
      "position": [
        1280,
        2944
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7424452f-e208-4e7e-8144-d0c6278bc0f0",
              "operator": {
                "type": "object",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json.body }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "dbb1f66e-69e3-411a-881c-5906c8acbaeb",
      "name": "Check: Email Found",
      "type": "n8n-nodes-base.if",
      "position": [
        2080,
        2944
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "acbd1ef3-0c59-48f4-9c04-342356a4f67d",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.email }}"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "65151b50-2695-4295-bb4d-7963cfff411f",
      "name": "Check: Retry Limit (Sheet Update)",
      "type": "n8n-nodes-base.if",
      "position": [
        3216,
        3120
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "51e191cb-af20-423b-9303-8523caa4ae0d",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $('Calc Retry Delay (Update Status)').item.json[\"retryCount\"] }}",
              "rightValue": 10
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "7ce53892-7626-427c-91b8-354c9c44bf51",
      "name": "Check: Retry Limit (Add Rows)",
      "type": "n8n-nodes-base.if",
      "position": [
        3216,
        2688
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "51e191cb-af20-423b-9303-8523caa4ae0d",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $('Calc Retry Delay (Add Rows)').item.json[\"retryCount\"] }}",
              "rightValue": 10
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b6d7bde5-1f6d-4d4f-b057-5df21d869231",
      "name": "Check: Retry Limit (Get Status)",
      "type": "n8n-nodes-base.if",
      "position": [
        3216,
        2896
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "51e191cb-af20-423b-9303-8523caa4ae0d",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $('Calc Retry Delay (Get Status)').item.json[\"retryCount\"] }}",
              "rightValue": 10
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "bf72fe4b-e03b-4501-b08c-0808673f7d4a",
      "name": "Wait: Backoff Before Retry (Add Rows)",
      "type": "n8n-nodes-base.wait",
      "position": [
        3008,
        2688
      ],
      "parameters": {
        "amount": "={{ $json[\"waitTimeInSeconds\"] }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "0d5159da-3649-4e39-b09a-28acc9673f69",
      "name": "Wait: Backoff Before Retry (Get Status)",
      "type": "n8n-nodes-base.wait",
      "position": [
        3008,
        2896
      ],
      "parameters": {
        "amount": "={{ $json[\"waitTime\"] }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "b99180a3-7e34-4873-b3ac-53fc447adf9f",
      "name": "Wait: Backoff Before Retry (Update Status)",
      "type": "n8n-nodes-base.wait",
      "position": [
        3008,
        3120
      ],
      "parameters": {
        "amount": "={{ $json[\"waitTime\"] }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "ba0641c4-a354-43ba-b6bb-7b35849c1187",
      "name": "Build Zip \u00d7 Category Matrix",
      "type": "n8n-nodes-base.code",
      "position": [
        2544,
        2416
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\n\n// Separate Zips and Categories into two arrays\nconst zips = [];\nconst categories = [];\n\nfor (const item of items) {\n    if (item.json.Zip) {\n        zips.push(item.json.Zip);\n    }\n    if (item.json.Categories) {\n        categories.push(item.json.Categories);\n    }\n}\n\n// Sanity check: make sure we have both lists\nif (zips.length === 0 || categories.length === 0) {\n    throw new Error('No zips or categories found in input data.');\n}\n\n// Cross-join: every Zip with every Category\nconst output = [];\n\nfor (const zip of zips) {\n    for (const category of categories) {\n        output.push({\n            json: {\n                Zip: zip,\n                Category: category\n            }\n        });\n    }\n}\n\nreturn output;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "e331a1fb-581c-4fcb-bb48-d4da4c5974db",
      "name": "Calc Retry Delay (Add Rows)",
      "type": "n8n-nodes-base.code",
      "position": [
        2816,
        2688
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Define the retry count (coming from a previous node or set manually)\nconst retryCount = $json[\"retryCount\"] || 0;  // If not present, default to 0\nconst maxRetries = 5;  // Define the maximum number of retries\nconst initialDelay = 1;  // Initial delay in seconds (1 second)\n\n// If the retry count is less than the max retries, calculate the delay\nif (retryCount < maxRetries) {\n    const currentDelayInSeconds = initialDelay * Math.pow(2, retryCount);  // Exponential backoff delay in seconds\n    \n    // Log the delay time for debugging\n    console.log(`Waiting for ${currentDelayInSeconds} seconds before retry...`);\n    \n    return {\n        json: {\n            retryCount: retryCount + 1,  // Increment retry count\n            waitTimeInSeconds: currentDelayInSeconds, // Pass the delay time in seconds\n            status: 'retrying',\n        }\n    };\n} else {\n    // If max retries are exceeded, return a failure response\n    return {\n        json: {\n            error: 'Max retries exceeded',\n            retryCount: retryCount,\n            status: 'failed'\n        }\n    };\n}\n"
      },
      "typeVersion": 2
    },
    {
      "id": "b6dc2f5d-71c4-4ed8-bca2-7afc36cd4571",
      "name": "Calc Retry Delay (Update Status)",
      "type": "n8n-nodes-base.code",
      "position": [
        2816,
        3120
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Define the retry count (coming from a previous node or set manually)\nconst retryCount = $json[\"retryCount\"] || 0;  // If not present, default to 0\nconst maxRetries = 5;  // Define the maximum number of retries\nconst initialDelay = 1;  // Initial delay in seconds (1 second)\n\n// If the retry count is less than the max retries, calculate the delay\nif (retryCount < maxRetries) {\n    const currentDelayInSeconds = initialDelay * Math.pow(2, retryCount);  // Exponential backoff delay in seconds\n    \n    // Log the delay time for debugging\n    console.log(`Waiting for ${currentDelayInSeconds} seconds before retry...`);\n    \n    return {\n        json: {\n            retryCount: retryCount + 1,  // Increment retry count\n            waitTimeInSeconds: currentDelayInSeconds, // Pass the delay time in seconds\n            status: 'retrying',\n        }\n    };\n} else {\n    // If max retries are exceeded, return a failure response\n    return {\n        json: {\n            error: 'Max retries exceeded',\n            retryCount: retryCount,\n            status: 'failed'\n        }\n    };\n}\n"
      },
      "typeVersion": 2
    },
    {
      "id": "68a96da3-8de8-4b4c-aafb-0f77b1ffd387",
      "name": "Calc Retry Delay (Get Status)",
      "type": "n8n-nodes-base.code",
      "position": [
        2816,
        2896
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "// Define the retry count (coming from a previous node or set manually)\nconst retryCount = $json[\"retryCount\"] || 0;  // If not present, default to 0\nconst maxRetries = 5;  // Define the maximum number of retries\nconst initialDelay = 1;  // Initial delay in seconds (1 second)\n\n// If the retry count is less than the max retries, calculate the delay\nif (retryCount < maxRetries) {\n    const currentDelayInSeconds = initialDelay * Math.pow(2, retryCount);  // Exponential backoff delay in seconds\n    \n    // Log the delay time for debugging\n    console.log(`Waiting for ${currentDelayInSeconds} seconds before retry...`);\n    \n    return {\n        json: {\n            retryCount: retryCount + 1,  // Increment retry count\n            waitTimeInSeconds: currentDelayInSeconds, // Pass the delay time in seconds\n            status: 'retrying',\n        }\n    };\n} else {\n    // If max retries are exceeded, return a failure response\n    return {\n        json: {\n            error: 'Max retries exceeded',\n            retryCount: retryCount,\n            status: 'failed'\n        }\n    };\n}\n"
      },
      "typeVersion": 2
    },
    {
      "id": "cbc869d8-c92b-42d0-8d84-963164a67f4a",
      "name": "Split Places Array",
      "type": "n8n-nodes-base.code",
      "position": [
        1488,
        2944
      ],
      "parameters": {
        "jsCode": "// Get the places array from the input data\nconst places = items[0]?.json?.body?.places || [];\n\n// Create an output array to hold each place as a separate item\nlet output = [];\n\nif (places.length > 0) {\n  for (let i = 0; i < places.length; i++) {\n    // For each place, push a new item into the output array\n    output.push({\n      json: {\n        place: places[i], // The individual place object\n\n        // \u2705 ADDED: websiteUri (safe access)\n        websiteUri: places[i]?.websiteUri || null,\n\n        otherData: items[0].json.otherData || null // unchanged\n      }\n    });\n  }\n} else {\n  // Log an error or handle the case where places array is empty or undefined\n  console.log('Places array is empty or undefined.');\n}\n\n// Return the output array, so each place becomes its own item\nreturn output;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "e11bad16-2550-4fe2-9432-27d20b0a8698",
      "name": "Extract Emails From Website",
      "type": "n8n-nodes-base.code",
      "onError": "continueRegularOutput",
      "position": [
        1872,
        2944
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const html = $json.data ?? '';\n\nconst cleanedText = html\n  .replace(/<script[\\s\\S]*?<\\/script>/gi, '')\n  .replace(/<style[\\s\\S]*?<\\/style>/gi, '')\n  .replace(/<[^>]+>/g, ' ')\n  .replace(/&nbsp;/gi, ' ')\n  .replace(/\\s+/g, ' ')\n  .trim()\n  .toLowerCase();\n\nconst emailRegex = /[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}/gi;\n\nconst matches = cleanedText.match(emailRegex) || [];\n\nconst blacklist = ['example.com', 'test.com', 'email.com', 'yourdomain.com'];\n\nconst emails = [...new Set(matches)].filter(e => !blacklist.some(b => e.includes(b)));\n\nconst placeData = $('Split Places Array').item.json.place;\n\nreturn {\n  place: placeData,\n  email: emails.length ? emails[0] : null\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "97c61d2c-23de-43dc-b90e-50a1f020525e",
      "name": "Check Follow Up 1 Date",
      "type": "n8n-nodes-base.code",
      "position": [
        4240,
        3584
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const today = new Date().toISOString().split(\"T\")[0];\n\n// Skip if intro not sent or lead inactive\nif (item.json.email_status !== \"yes\") {\n  return null;\n}\n\n// Follow-up 1\nif (\n  item.json[\"follow up email send date 1\"] === today &&\n  item.json[\"follow up mail 1 status\"] === \"no\"\n) {\n  item.json.body = item.json[\"follow up mail 1\"];\n  item.json.send_type = \"fu1\";\n  return item;\n}\n\n// Nothing to send\nreturn null;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "20b156c9-e10b-458e-a082-582dbcac93ab",
      "name": "Check Follow Up 2 Date",
      "type": "n8n-nodes-base.code",
      "position": [
        2256,
        4112
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": " const today = new Date().toISOString().split(\"T\")[0];\n\n// Skip if intro not sent or lead inactive\nif (item.json.email_status !== \"yes\") {\n  return null;\n}\n\n// Follow-up 2\nif (\n  item.json[\"follow up email send date 2\"] === today &&\n  item.json[\"follow up mail 2 status\"] === \"no\"\n) {\n  item.json.body = item.json[\"follow up mail 2\"];\n  item.json.send_type = \"fu2\";\n  return item;\n}\n\n// Nothing to send\nreturn null;"
      },
      "typeVersion": 2
    },
    {
      "id": "59dc95f3-9a31-45fd-a86d-0e71e3f09470",
      "name": "Generate Follow Up Dates",
      "type": "n8n-nodes-base.code",
      "position": [
        2528,
        3552
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const today = new Date();\n\nfunction addDays(date, days) {\n  const d = new Date(date);\n  d.setDate(d.getDate() + days);\n  return d.toISOString().split(\"T\")[0];\n}\n\nitem.json.intro_date = addDays(today, 0);\nitem.json.fu1_date = addDays(today, 7);\nitem.json.fu2_date = addDays(today, 11);\n\nitem.json.intro_sent = \"yes\";\nitem.json.fu1_sent = \"no\";\nitem.json.fu2_sent = \"no\";\n\nreturn item;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "9abdef30-5701-43a4-9fcb-8c8b366027b8",
      "name": "Limit: Zips Per Run",
      "type": "n8n-nodes-base.limit",
      "position": [
        1840,
        2384
      ],
      "parameters": {
        "maxItems": 3
      },
      "typeVersion": 1
    },
    {
      "id": "0a983063-3545-4b44-b3f1-92e5abe7eec9",
      "name": "Map Zip Field",
      "type": "n8n-nodes-base.set",
      "position": [
        2128,
        2352
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a392c381-2f67-4638-94ae-e49df0296503",
              "name": "Zip",
              "type": "string",
              "value": "={{ $json.Zip }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e9aa4fda-6d88-4aa0-b673-ecc296dad94c",
      "name": "Merge Zips & Categories",
      "type": "n8n-nodes-base.merge",
      "position": [
        2336,
        2416
      ],
      "parameters": {},
      "typeVersion": 3.1
    },
    {
      "id": "a57bed18-2de2-443e-b2c4-0a6a003e5501",
      "name": "Loop: Generate AI Emails",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        64,
        3584
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "9d8e3003-9db2-40f0-ac19-7ae176937dc1",
      "name": "Loop: Send Follow Up 1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        4000,
        3568
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "c765c94b-ef11-484f-93eb-77e730b6c060",
      "name": "Loop: Send Follow Up 2",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1968,
        4096
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "7cb0b910-6588-46e2-bc65-3063ad01474c",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        2288
      ],
      "parameters": {
        "color": 2,
        "width": 1664,
        "height": 384,
        "content": "## Lead discovery\n\nReads ZIP codes and business categories from Google Sheets, then queries Google Maps to find matching local businesses.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "018d0d08-5a8a-493e-8db3-90cc3077ca67",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2240,
        3472
      ],
      "parameters": {
        "width": 672,
        "height": 272,
        "content": "## Intro send\nSends first outreach email and stores message ID.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7f24779c-8609-4e0a-8101-da3c0be67499",
      "name": "Loop: Send Intro Emails",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        2048,
        3536
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "9fe45cba-8440-471b-9364-55d7167adbee",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4192,
        3504
      ],
      "parameters": {
        "width": 672,
        "height": 272,
        "content": "## Follow up 1\nReplies to intro email after 7 days.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "4375ab38-7cd9-4f7e-b02a-630ec3967637",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2208,
        4032
      ],
      "parameters": {
        "width": 672,
        "height": 272,
        "content": "## Follow up 2\nFinal reply after 11 days.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "65d56998-b334-4aae-9b3f-44627bf09a6b",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2960,
        2592
      ],
      "parameters": {
        "width": 592,
        "height": 736,
        "content": "## Rate limit handling\nPrevents Google Sheets API limits using\nexponential backoff and retries.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "7197a728-7220-41fe-a733-31503217f75b",
  "connections": {
    "Zips": {
      "main": [
        [
          {
            "node": "Filter Zips",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Zip": {
      "main": [
        [
          {
            "node": "Loop Subcats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Zip1": {
      "main": [
        [
          {
            "node": "GMaps API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Get Zip Codes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GMaps API": {
      "main": [
        [
          {
            "node": "Check: GMaps Result Empty",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Limit: Zips Per Run",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Status": {
      "main": [
        [
          {
            "node": "Update Status to Success",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Calc Retry Delay (Get Status)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape URL": {
      "main": [
        [
          {
            "node": "Extract Emails From Website",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Zips": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Writer": {
      "main": [
        [
          {
            "node": "Update row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Category": {
      "main": [
        [
          {
            "node": "Merge Zips & Categories",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Loop Subcats": {
      "main": [
        [],
        [
          {
            "node": "Set Zip1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Zip Codes": {
      "main": [
        [
          {
            "node": "Zips",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Zip Field": {
      "main": [
        [
          {
            "node": "Merge Zips & Categories",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Intro Mail": {
      "main": [
        [
          {
            "node": "Generate Follow Up Dates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Follow Up Mail 1": {
      "main": [
        [
          {
            "node": "Update row with follow up status 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Follow Up Mail 2": {
      "main": [
        [
          {
            "node": "Update row in sheet3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check: Email Found": {
      "main": [
        [
          {
            "node": "Add rows in Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Places Array": {
      "main": [
        [
          {
            "node": "Scrape URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "Check: Intro Mail Empty",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit: Zips Per Run": {
      "main": [
        [
          {
            "node": "Map Zip Field",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Category",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update row in sheet": {
      "main": [
        [
          {
            "node": "Loop: Generate AI Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet1": {
      "main": [
        [
          {
            "node": "Check: Intro Ready & Not Sent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet4": {
      "main": [
        [
          {
            "node": "Check: Follow Up 1 Due",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet5": {
      "main": [
        [
          {
            "node": "Check: Follow Up 2 Due",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update row in sheet3": {
      "main": [
        [
          {
            "node": "Loop: Send Follow Up 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Follow Up 1 Date": {
      "main": [
        [
          {
            "node": "Follow Up Mail 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Follow Up 2 Date": {
      "main": [
        [
          {
            "node": "Follow Up Mail 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check: Follow Up 1 Due": {
      "main": [
        [
          {
            "node": "Loop: Send Follow Up 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check: Follow Up 2 Due": {
      "main": [
        [
          {
            "node": "Loop: Send Follow Up 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop: Send Follow Up 1": {
      "main": [
        [],
        [
          {
            "node": "Check Follow Up 1 Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop: Send Follow Up 2": {
      "main": [
        [],
        [
          {
            "node": "Check Follow Up 2 Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check: Intro Mail Empty": {
      "main": [
        [
          {
            "node": "Loop: Generate AI Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop: Send Intro Emails": {
      "main": [
        [],
        [
          {
            "node": "Send Intro Mail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Zips & Categories": {
      "main": [
        [
          {
            "node": "Build Zip \u00d7 Category Matrix",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Follow Up Dates": {
      "main": [
        [
          {
            "node": "Update Row with all Follow Up Mail Dates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop: Generate AI Emails": {
      "main": [
        [],
        [
          {
            "node": "Email Writer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Status to Success": {
      "main": [
        [
          {
            "node": "Loop Subcats",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Calc Retry Delay (Update Status)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add rows in Google Sheets": {
      "main": [
        [
          {
            "node": "Get Status",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Calc Retry Delay (Add Rows)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check: GMaps Result Empty": {
      "main": [
        [
          {
            "node": "Loop Subcats",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Split Places Array",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger: Send Follow Up 1": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger: Send Follow Up 2": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger: Send Intro Emails": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calc Retry Delay (Add Rows)": {
      "main": [
        [
          {
            "node": "Wait: Backoff Before Retry (Add Rows)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Emails From Website": {
      "main": [
        [
          {
            "node": "Check: Email Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger: Generate AI Emails": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Zip \u00d7 Category Matrix": {
      "main": [
        [
          {
            "node": "Set Zip",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calc Retry Delay (Get Status)": {
      "main": [
        [
          {
            "node": "Wait: Backoff Before Retry (Get Status)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check: Intro Ready & Not Sent": {
      "main": [
        [
          {
            "node": "Loop: Send Intro Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check: Retry Limit (Add Rows)": {
      "main": [
        [
          {
            "node": "Stop and Error1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Add rows in Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger: Lead Scraping (GMaps)": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check: Retry Limit (Get Status)": {
      "main": [
        [
          {
            "node": "Stop and Error2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calc Retry Delay (Update Status)": {
      "main": [
        [
          {
            "node": "Wait: Backoff Before Retry (Update Status)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check: Retry Limit (Sheet Update)": {
      "main": [
        [
          {
            "node": "Stop and Error",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update Status to Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update row with follow up status 1": {
      "main": [
        [
          {
            "node": "Loop: Send Follow Up 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait: Backoff Before Retry (Add Rows)": {
      "main": [
        [
          {
            "node": "Check: Retry Limit (Add Rows)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait: Backoff Before Retry (Get Status)": {
      "main": [
        [
          {
            "node": "Check: Retry Limit (Get Status)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Row with all Follow Up Mail Dates": {
      "main": [
        [
          {
            "node": "Loop: Send Intro Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait: Backoff Before Retry (Update Status)": {
      "main": [
        [
          {
            "node": "Check: Retry Limit (Sheet Update)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}