{
  "id": "uk3BJzTDWtW6AJ4r",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Apollo Business Hunter",
  "tags": [
    {
      "id": "WFqlVX5a7BJV6ub6",
      "name": "Demo",
      "createdAt": "2026-01-21T06:04:18.770Z",
      "updatedAt": "2026-01-21T06:04:18.770Z"
    }
  ],
  "nodes": [
    {
      "id": "84aa57d5-f612-41d0-922a-afb68c84da7a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        -672
      ],
      "parameters": {
        "width": 1814,
        "height": 832,
        "content": "\n\nThis workflow creates a fully automated B2B lead generation & outreach pipeline. It combines **BrowserAct** (for scraping) with **Google Gemini AI** (for writing) to automate the entire prospecting process.\n\nIt takes a search request via a Form, scrapes verified leads from Apollo.io, uses AI to write a personalized cold email for EACH lead, saves everything to Google Sheets, and notifies you via Gmail when the batch is done.\n\n## How it works\n* **Form Trigger:** You input the Target Role (e.g., \"Engineer\") and Location (e.g., \"New York\").\n* **BrowserAct Automation:** Triggers a remote browser to search Apollo.io and extract contact details (Name, Job, Company, Email).\n* **AI Email Drafter:** **Google Gemini** reads the lead's info and automatically generates a personalized cold email draft tailored to their role and company.\n* **Data Merging:** Seamlessly combines the scraped contact info with the AI-generated email content.\n* **Google Sheets Storage:** Appends the full profile + the AI email draft into your spreadsheet.\n* **Email Notification:** Sends you a summary report via **Gmail** listing who was scraped and confirming the job is finished.\n\n## Set up steps\n1.  **BrowserAct Configuration**\n    * Double-click the \"Run a workflow\" node and paste your specific **BrowserAct Workflow ID**.\n2.  **Google Sheets Setup**\n    * Create a new Google Sheet.\n    * **Crucial:** Add these headers in the first row: `id`, `name`, `email`, `job_title`, `profile_url`, `company`, `location`, `email_draft`.\n    * Update the \"Save to Google Sheets\" node to select this file.\n3.  **Credentials**\n    * **BrowserAct Account**\n    * **Google Gemini (PaLM) API** (for AI generation)\n    * **Google Sheets** (Service Account or OAuth2)\n    * **Gmail** (OAuth2 - for notifications)"
      },
      "typeVersion": 1
    },
    {
      "id": "bb066dca-a05a-4798-a048-554398681909",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        160
      ],
      "parameters": {
        "color": 3,
        "width": 400,
        "height": 320,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\nTitle: Data collection\n\nText: Accepts target role and location inputs via a form, then triggers a BrowserAct workflow to perform a real-browser search and scrape contact data from Apollo.io.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "fabd1269-acaa-406e-9bc9-4b9dcdaf3c07",
      "name": "Receive Lead Criteria",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        112
      ],
      "parameters": {
        "options": {},
        "formTitle": "Lead Gen Request",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Location",
              "placeholder": "Austin ",
              "requiredField": true
            },
            {
              "fieldLabel": "Bussines_Category",
              "placeholder": "accountant",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Fill this to tailor your request"
      },
      "typeVersion": 2.2
    },
    {
      "id": "eb461384-7ed7-443a-a09c-1060e76134b8",
      "name": "Scrape Apollo via BrowserAct",
      "type": "n8n-nodes-browseract.browserAct",
      "position": [
        192,
        112
      ],
      "parameters": {
        "type": "WORKFLOW",
        "workflowId": "70144352397874162",
        "workflowConfig": {
          "value": {
            "input-Location": "={{ $json.Location }}",
            "input-Bussines_Category": "={{ $json.Bussines_Category }}"
          },
          "schema": [
            {
              "id": "input-ApoloAI_Search",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "description": "If left blank, the default value defined in BrowserAct will be used.",
              "displayName": "ApoloAI_Search",
              "defaultMatch": true
            },
            {
              "id": "input-Location",
              "type": "string",
              "display": true,
              "removed": false,
              "required": true,
              "description": "Location is required",
              "displayName": "* Location",
              "defaultMatch": true
            },
            {
              "id": "input-Bussines_Category",
              "type": "string",
              "display": true,
              "removed": false,
              "required": true,
              "description": "Bussines_Category is required",
              "displayName": "* Bussines_Category",
              "defaultMatch": true
            },
            {
              "id": "input-ApoloAi_Login",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "description": "If left blank, the default value defined in BrowserAct will be used.",
              "displayName": "ApoloAi_Login",
              "defaultMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "input-ApoloAI_Search",
            "input-Location",
            "input-Bussines_Category",
            "input-ApoloAi_Login"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "credentials": {
        "browserActApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6a962e82-03de-430f-8f1c-e8a26b15f291",
      "name": "Clean & Flatten JSON",
      "type": "n8n-nodes-base.code",
      "position": [
        400,
        112
      ],
      "parameters": {
        "jsCode": "\nconst raw = $json?.output?.string ?? $json?.output;\n\nlet parsed;\ntry {\n  parsed = (typeof raw === 'string') ? JSON.parse(raw) : raw;\n} catch (e) {\n  \n  parsed = [];\n}\n\nconst blocks = Array.isArray(parsed) ? parsed : (parsed ? [parsed] : []);\n\nconst results = [];\n\nfor (const block of blocks) {\n  const items = Array.isArray(block?.item) ? block.item : [];\n  for (const person of items) {\n    const email = person?.email || '';\n    const links = person?.links || '';\n    const name = person?.name || '';\n    const company = person?.company || '';\n\n    results.push({\n      id: email || links || `${name}-${company}`,\n      name,\n      job_title: person?.job_title || '',\n      email,\n      profile_url: links,     \n      company,\n      location: person?.location || '',\n    });\n  }\n}\n\nreturn results.map(r => ({ json: r }));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "fae89d3e-4bbd-4f7b-8182-9ce6fa79be32",
      "name": "Map Columns",
      "type": "n8n-nodes-base.set",
      "position": [
        1136,
        112
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e45d7aab-0f67-4ca1-9ffb-02337c56d83e",
              "name": "name",
              "type": "string",
              "value": "={{ $json.name }}"
            },
            {
              "id": "34334186-df38-4d28-a3b9-1c3654fd1f38",
              "name": "job_title",
              "type": "string",
              "value": "={{ $json.job_title }}"
            },
            {
              "id": "326d9ea4-de08-463a-94cd-c3054f5a24e1",
              "name": "email",
              "type": "string",
              "value": "={{ $json.email }}"
            },
            {
              "id": "23d4c925-b7de-48ab-8880-788be5657c89",
              "name": "profile_url",
              "type": "string",
              "value": "={{ $json.profile_url }}"
            },
            {
              "id": "cb0b1338-4973-4d21-85e0-a166ca626a71",
              "name": "company",
              "type": "string",
              "value": "={{ $json.company }}"
            },
            {
              "id": "d8428394-595c-4f60-9fd1-db90f585d53d",
              "name": "location",
              "type": "string",
              "value": "={{ $json.location }}"
            },
            {
              "id": "2e428470-eea5-417f-9ad3-ad008a2963e1",
              "name": "email_draft",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d231f3f9-e3cf-428d-83f8-7abfe613df47",
      "name": "Save to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1344,
        112
      ],
      "parameters": {
        "columns": {
          "value": {
            "id": "={{ $now.format('x') }}-{{ Math.random().toString(36).substr(2, 9) }}",
            "name": "={{ $json.name }}",
            "email": "={{ $json.email }}",
            "company": "={{ $json.company }}",
            "location": "={{ $json.location }}",
            "job_title": "={{ $json.job_title }}",
            "email_draft": "={{ $json.email_draft }}",
            "profile_url": "={{ $json.profile_url }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "job_title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "job_title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "profile_url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "profile_url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "company",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "company",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "location",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "location",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "email_draft",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "email_draft",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 971059340,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1znh4t8qgqvRVe1ZGCteM5F0mapxCyjEHegsK2K5yF24/edit#gid=971059340",
          "cachedResultName": "sheet002"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1znh4t8qgqvRVe1ZGCteM5F0mapxCyjEHegsK2K5yF24",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1znh4t8qgqvRVe1ZGCteM5F0mapxCyjEHegsK2K5yF24/edit?usp=drivesdk",
          "cachedResultName": "n8n"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "a82c3e62-5381-44de-bff5-a2836eebe854",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        336,
        160
      ],
      "parameters": {
        "color": 4,
        "width": 944,
        "height": 320,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n**Title:** AI Enrichment & Processing\n\n**Text:**\n1. **Clean:** Standardizes the raw scraped JSON data.\n2. **AI Write:** Uses **Google Gemini** to analyze each lead and generate a personalized cold email draft automatically.\n3. **Merge:** Combines the original contact info with the AI-generated email content into a single dataset."
      },
      "typeVersion": 1
    },
    {
      "id": "325d49e5-9b43-45d0-ae60-b02d58d5996f",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1280,
        160
      ],
      "parameters": {
        "color": 6,
        "width": 464,
        "height": 320,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n**Title:** Storage & Notification\n\n**Text:**\n1. **Save:** Appends the verified lead profile + AI email draft to **Google Sheets**.\n2. **Notify:** Sends a summary report to your **Gmail** once the batch is finished, listing how many leads were captured."
      },
      "typeVersion": 1
    },
    {
      "id": "91918acc-424b-414f-a844-ab0b8232961f",
      "name": "Basic LLM Chain",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        592,
        112
      ],
      "parameters": {
        "text": "=You are a professional B2B sales expert. Write a short, engaging cold email to {{ $json.name }}, who is the {{ $json.job_title }} at {{ $json.company }}.\n\nThe goal is to introduce our 'Automated Lead Generation Service'.\nKeep it under 100 words. Be polite and professional.",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "bd333a82-bbe9-414a-8294-a3600b362f09",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        736,
        240
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "da01a792-359a-4df8-995c-85488ad3bba0",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1552,
        112
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=Task Completed! \ud83d\ude80\n\nA total of {{ $input.all().length }} potential leads have been successfully collected and processed.\n\n\ud83d\udccb Lead List:\n{{ $input.all().map(item => item.json.name + \" (\" + item.json.company + \")\").join('\\n') }}\n\n\u2705 AI-generated outreach emails have been created and saved.\nPlease check the spreadsheet:\nhttps://docs.google.com/spreadsheets/d/1znh4t8qgqvRVe1ZGCteM5F0mapxCyjEHegsK2K5yF24/edit?gid=971059340#gid=971059340\n",
        "options": {},
        "subject": "[n8n Notification] Leads Successfully Collected & Outreach Emails Generated!"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "executeOnce": true,
      "typeVersion": 2.2
    },
    {
      "id": "2e075597-3f31-460e-9ff2-cfe9d3206c48",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        912,
        -48
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.2
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "228bbb02-d044-447f-809f-b64ae5a6268d",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Map Columns",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Columns": {
      "main": [
        [
          {
            "node": "Save to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Clean & Flatten JSON": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive Lead Criteria": {
      "main": [
        [
          {
            "node": "Scrape Apollo via BrowserAct",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Google Sheets": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Apollo via BrowserAct": {
      "main": [
        [
          {
            "node": "Clean & Flatten JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}