{
  "name": "B2B Lead Generation Pipeline — Google Maps → Email Verification → Google Sheets",
  "meta": {
    "instanceId": "noniner-template-b2b-lead-gen-v1",
    "templateCredsSetupCompleted": false
  },
  "description": "Takes a Google Maps search query (e.g. 'SaaS companies London'), runs No Niner's Google Maps Lead Enricher to find businesses with emails and decision-maker contacts, verifies every email address, filters to verified leads only, appends to Google Sheets, and sends a summary email. Run on demand or on a schedule.",
  "nodes": [
    {
      "id": "sticky-overview",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-260, 60],
      "parameters": {
        "content": "## B2B Lead Generation Pipeline\n\n**What it does**\n1. Takes a Google Maps search query (e.g. \"SaaS startups Berlin\")\n2. Runs No Niner's Google Maps Lead Enricher — finds businesses + enriches with emails and decision-maker contacts\n3. Verifies every email address (SMTP + MX check)\n4. Filters to verified leads only\n5. Appends to Google Sheets\n6. Sends a summary email with lead count\n\n**Setup (5 min)**\n- `Apify Token` — free at apify.com/sign-up\n- `Gmail OAuth` — connect your Google account\n- `Google Sheets` — create a Leads sheet and paste the ID\n\n**Run mode**\nUse the *Manual Trigger* for on-demand campaigns, or swap it for a *Schedule Trigger* for recurring prospecting.",
        "width": 440,
        "height": 700,
        "color": 5
      }
    },
    {
      "id": "sticky-search",
      "name": "Sticky Search",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [300, 60],
      "parameters": {
        "content": "**Step 1 — Configure**\nSet your ICP: search query, max results and industry filter.\n\nExamples:\n- `\"marketing agencies Amsterdam\"`\n- `\"B2B SaaS Copenhagen\"`\n- `\"fintech startups Stockholm\"`",
        "width": 220,
        "height": 180,
        "color": 7
      }
    },
    {
      "id": "sticky-enrich",
      "name": "Sticky Enrich",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [780, 60],
      "parameters": {
        "content": "**Step 2 — Enrich + Verify**\nGoogle Maps Lead Enricher finds businesses matching your query and infers decision-maker emails.\n\nEmail Verifier then checks each address via SMTP — only verified emails reach your Sheets.",
        "width": 220,
        "height": 180,
        "color": 7
      }
    },
    {
      "id": "sticky-output",
      "name": "Sticky Output",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [1340, 60],
      "parameters": {
        "content": "**Step 3 — Output**\nVerified leads go to Google Sheets with: company name, domain, email, job title, LinkedIn URL, phone.\n\nA summary email confirms how many verified leads were added.",
        "width": 220,
        "height": 180,
        "color": 7
      }
    },
    {
      "id": "manual-trigger",
      "name": "Run Campaign",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [320, 300],
      "parameters": {}
    },
    {
      "id": "set-icp",
      "name": "Set ICP Config",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [520, 300],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "search-query",
              "name": "search_query",
              "value": "SaaS companies London",
              "type": "string"
            },
            {
              "id": "max-results",
              "name": "max_results",
              "value": "50",
              "type": "string"
            },
            {
              "id": "notify-email",
              "name": "notify_email",
              "value": "you@company.com",
              "type": "string"
            },
            {
              "id": "sheets-id",
              "name": "sheets_id",
              "value": "YOUR_GOOGLE_SHEET_ID",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "http-maps-enricher",
      "name": "Google Maps Lead Enricher",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [760, 300],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/noniner~google-maps-lead-enricher/run-sync-get-dataset-items",
        "method": "POST",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "queryParameters": {
          "parameters": [
            { "name": "token", "value": "={{ $credentials.apifyApiToken }}" },
            { "name": "timeout", "value": "120" },
            { "name": "maxItems", "value": "={{ $json.max_results }}" }
          ]
        },
        "contentType": "json",
        "body": {
          "searchQuery": "={{ $json.search_query }}",
          "maxResults": "={{ parseInt($json.max_results) }}",
          "findEmails": true,
          "findLinkedIn": true
        },
        "options": {}
      },
      "credentials": {
        "httpQueryAuth": {
          "id": "apify-token",
          "name": "Apify Token"
        }
      }
    },
    {
      "id": "code-filter-with-email",
      "name": "Filter Leads with Email",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [980, 300],
      "parameters": {
        "jsCode": "// Keep only leads that have an email address to verify.\nconst items = $input.all();\nconst withEmail = items.filter(item => {\n  const email = item.json.email || item.json.decisionMakerEmail || '';\n  return email && email.includes('@') && !email.includes('noemail');\n});\n\nconsole.log(`Total leads: ${items.length}, with email: ${withEmail.length}`);\n\nreturn withEmail.map(item => ({\n  json: {\n    ...item.json,\n    emailToVerify: item.json.email || item.json.decisionMakerEmail\n  }\n}));"
      }
    },
    {
      "id": "http-verify-email",
      "name": "Verify Email",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [1200, 300],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/noniner~b2b-email-verifier/run-sync-get-dataset-items",
        "method": "POST",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "queryParameters": {
          "parameters": [
            { "name": "token", "value": "={{ $credentials.apifyApiToken }}" },
            { "name": "timeout", "value": "60" },
            { "name": "maxItems", "value": "1" }
          ]
        },
        "contentType": "json",
        "body": {
          "emails": ["={{ $json.emailToVerify }}"]
        },
        "options": {}
      },
      "credentials": {
        "httpQueryAuth": {
          "id": "apify-token",
          "name": "Apify Token"
        }
      }
    },
    {
      "id": "if-verified",
      "name": "Email Verified?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [1420, 300],
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": false, "leftValue": "", "typeValidation": "loose" },
          "conditions": [
            {
              "id": "cond-verified",
              "leftValue": "={{ $json[0]?.status || $json[0]?.result || '' }}",
              "rightValue": "valid",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            }
          ],
          "combinator": "and"
        }
      }
    },
    {
      "id": "sheets-add-lead",
      "name": "Add Verified Lead",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4,
      "position": [1640, 160],
      "parameters": {
        "resource": "sheet",
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Set ICP Config').first().json.sheets_id }}"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Leads"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Date Added": "={{ new Date().toISOString().split('T')[0] }}",
            "Company": "={{ $('Filter Leads with Email').item.json.companyName || $('Filter Leads with Email').item.json.name || '' }}",
            "Domain": "={{ $('Filter Leads with Email').item.json.domain || $('Filter Leads with Email').item.json.website || '' }}",
            "Email": "={{ $('Filter Leads with Email').item.json.emailToVerify }}",
            "Contact Name": "={{ $('Filter Leads with Email').item.json.decisionMakerName || '' }}",
            "Title": "={{ $('Filter Leads with Email').item.json.decisionMakerTitle || '' }}",
            "LinkedIn": "={{ $('Filter Leads with Email').item.json.linkedinUrl || '' }}",
            "Phone": "={{ $('Filter Leads with Email').item.json.phone || '' }}",
            "City": "={{ $('Filter Leads with Email').item.json.city || '' }}",
            "Search Query": "={{ $('Set ICP Config').first().json.search_query }}"
          }
        },
        "options": {}
      }
    },
    {
      "id": "noop-unverified",
      "name": "Skip Unverified",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [1640, 440]
    },
    {
      "id": "gmail-summary",
      "name": "Email Lead Summary",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [1880, 300],
      "parameters": {
        "resource": "message",
        "operation": "send",
        "sendTo": "={{ $('Set ICP Config').first().json.notify_email }}",
        "subject": "Lead Generation Complete — {{ $('Set ICP Config').first().json.search_query }}",
        "emailType": "text",
        "message": "Lead generation run complete.\n\nSearch query: {{ $('Set ICP Config').first().json.search_query }}\nDate: {{ new Date().toISOString().split('T')[0] }}\n\nResults have been added to your Google Sheets tab (Leads).\n\nTip: sort by 'Date Added' to see the new batch.\n\nPowered by No Niner Google Maps Lead Enricher — noniner.io",
        "options": {}
      }
    }
  ],
  "connections": {
    "Run Campaign": {
      "main": [[{ "node": "Set ICP Config", "type": "main", "index": 0 }]]
    },
    "Set ICP Config": {
      "main": [[{ "node": "Google Maps Lead Enricher", "type": "main", "index": 0 }]]
    },
    "Google Maps Lead Enricher": {
      "main": [[{ "node": "Filter Leads with Email", "type": "main", "index": 0 }]]
    },
    "Filter Leads with Email": {
      "main": [[{ "node": "Verify Email", "type": "main", "index": 0 }]]
    },
    "Verify Email": {
      "main": [[{ "node": "Email Verified?", "type": "main", "index": 0 }]]
    },
    "Email Verified?": {
      "main": [
        [{ "node": "Add Verified Lead", "type": "main", "index": 0 }],
        [{ "node": "Skip Unverified", "type": "main", "index": 0 }]
      ]
    },
    "Add Verified Lead": {
      "main": [[{ "node": "Email Lead Summary", "type": "main", "index": 0 }]]
    },
    "Skip Unverified": {
      "main": [[{ "node": "Email Lead Summary", "type": "main", "index": 0 }]]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": ""
  },
  "staticData": null
}
