{
  "id": "k6iHcGIKwMWLeP0W",
  "name": "Local Business Outbound Lead Finder",
  "tags": [],
  "nodes": [
    {
      "id": "83c7afa8-3ced-45b7-b9aa-f0d579cd655c",
      "name": "README",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 620,
        "height": 500,
        "content": "## \ud83d\uddfa\ufe0f Local Business Outbound Lead Finder\n\n**What this workflow does:**\n1. User picks a **Business Type** + **Location** from the form\n2. **SearchAPI Google Maps** finds matching local businesses\n3. Parses: name, category, address, phone, website, rating, review count, price range\n4. Writes all enriched leads to a **Google Sheet**\n\n---\n\n**\ud83d\udccb Columns written to Sheet:**\n`Business Name` \u00b7 `Category` \u00b7 `Address` \u00b7 `Phone` \u00b7 `Website` \u00b7 `Rating` \u00b7 `Review Count` \u00b7 `Price Range` \u00b7 `Location` \u00b7 `Business Type` \u00b7 `Maps URL` \u00b7 `Place ID` \u00b7 `Run ID` \u00b7 `Scraped At`\n\n---\n\n**\u2699\ufe0f Setup required:**\n1. Connect your **SearchAPI** credential (get a free key at searchapi.io)\n2. Connect your **Google Sheets OAuth2** credential\n3. In the **\"Write to Google Sheet\"** node, select your target spreadsheet and sheet tab\n4. Customize the **Business Type** and **Location** dropdowns in the form as needed\n\n**SearchAPI engine:** `google_maps`\n**Query pattern:** `{Business Type} in {Location}`"
      },
      "typeVersion": 1
    },
    {
      "id": "fd4c3c2c-098f-4d75-be23-a92bda81154b",
      "name": "Lead Search Form",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        720,
        64
      ],
      "parameters": {
        "options": {},
        "formTitle": "Find Local Business Leads",
        "formFields": {
          "values": [
            {
              "fieldType": "dropdown",
              "fieldLabel": "Business Type",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Gym"
                  },
                  {
                    "option": "Salon"
                  },
                  {
                    "option": "Restaurant"
                  },
                  {
                    "option": "Dental Clinic"
                  },
                  {
                    "option": "Digital Marketing Agency"
                  },
                  {
                    "option": "Law Firm"
                  },
                  {
                    "option": "Real Estate Agency"
                  },
                  {
                    "option": "Accounting Firm"
                  },
                  {
                    "option": "Yoga Studio"
                  },
                  {
                    "option": "Coffee Shop"
                  },
                  {
                    "option": "Coaching Institute"
                  },
                  {
                    "option": "IT Company"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Location",
              "fieldOptions": {
                "values": [
                  {
                    "option": "Mumbai"
                  },
                  {
                    "option": "Delhi"
                  },
                  {
                    "option": "Bangalore"
                  },
                  {
                    "option": "Hyderabad"
                  },
                  {
                    "option": "Chennai"
                  },
                  {
                    "option": "Pune"
                  },
                  {
                    "option": "Kolkata"
                  },
                  {
                    "option": "Ahmedabad"
                  },
                  {
                    "option": "Noida"
                  },
                  {
                    "option": "Gurgaon"
                  },
                  {
                    "option": "Jaipur"
                  },
                  {
                    "option": "Surat"
                  }
                ]
              },
              "requiredField": true
            }
          ]
        },
        "formDescription": "Select a business type and location. Matching businesses will be enriched and added to your Google Sheet."
      },
      "typeVersion": 2.2
    },
    {
      "id": "51e6de8a-49de-4dae-a6c3-8336afb3e9cb",
      "name": "Build Search Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        992,
        64
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "s1",
              "name": "businessType",
              "type": "string",
              "value": "={{ $json['Business Type'] }}"
            },
            {
              "id": "s2",
              "name": "location",
              "type": "string",
              "value": "={{ $json['Location'] }}"
            },
            {
              "id": "s3",
              "name": "searchQuery",
              "type": "string",
              "value": "={{ $json['Business Type'] + ' in ' + $json['Location'] }}"
            },
            {
              "id": "s4",
              "name": "runId",
              "type": "string",
              "value": "={{ 'RUN-' + $now.toFormat('yyyyMMdd-HHmmss') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b1b07b1f-f5ac-4c2e-8cb7-52f96b9a175b",
      "name": "SearchAPI \u2014 Google Maps",
      "type": "@searchapi/n8n-nodes-searchapi.searchApi",
      "position": [
        1248,
        64
      ],
      "parameters": {
        "q": "={{ $json.searchQuery }}",
        "resource": "google_maps",
        "pagination": {},
        "requestOptions": {},
        "locationSettings": {},
        "searchConfiguration": {}
      },
      "typeVersion": 1
    },
    {
      "id": "47c6679a-2d95-40ac-aa28-98d8101e54ba",
      "name": "Parse Business Results",
      "type": "n8n-nodes-base.code",
      "position": [
        1504,
        64
      ],
      "parameters": {
        "jsCode": "// Parse local_results from SearchAPI Google Maps response\n// Each result may contain: title, address, phone, website, rating, reviews, type, place_id\n\nconst vars = $('Build Search Variables').first().json;\nconst businessType = vars.businessType || '';\nconst location     = vars.location     || '';\nconst runId        = vars.runId        || '';\n\nconst leads = [];\n\nfor (const item of $input.all()) {\n  const localResults = item.json.local_results || [];\n\n  for (const r of localResults) {\n    if (!r.title) continue;\n\n    leads.push({\n      'Business Name':  r.title         || '',\n      'Category':       r.type          || businessType,\n      'Address':        r.address       || '',\n      'Phone':          r.phone         || '',\n      'Website':        r.website       || '',\n      'Rating':         r.rating        || '',\n      'Review Count':   r.reviews       || '',\n      'Price Range':    r.price         || '',\n      'Location':       location,\n      'Business Type':  businessType,\n      'Maps URL':       r.maps_url      || r.direction || '',\n      'Place ID':       r.place_id      || '',\n      'Run ID':         runId,\n      'Scraped At':     new Date().toISOString()\n    });\n  }\n}\n\nif (leads.length === 0) {\n  return [{ json: { error: 'No results found for ' + businessType + ' in ' + location } }];\n}\n\nreturn leads.map(l => ({ json: l }));"
      },
      "typeVersion": 2
    },
    {
      "id": "7d524fd5-a093-48d9-93c6-05af5a184ca0",
      "name": "Write to Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1760,
        64
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "\ud83d\udccc Select your Sheet Tab"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "\ud83d\udccc Select your Google Sheet"
        }
      },
      "typeVersion": 4.7
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "34be8cb5-dc43-45f9-95d5-3802fbb331f1",
  "connections": {
    "Lead Search Form": {
      "main": [
        [
          {
            "node": "Build Search Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Search Variables": {
      "main": [
        [
          {
            "node": "SearchAPI \u2014 Google Maps",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Business Results": {
      "main": [
        [
          {
            "node": "Write to Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SearchAPI \u2014 Google Maps": {
      "main": [
        [
          {
            "node": "Parse Business Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}