← All posts
How-ToAugust 10, 2026 · 4 min

How to automate lead generation with AI: Build a lead-enrichment pipeline that writes your icebreaker

How do you automate lead generation with AI? You set up a workflow that scrapes prospect URLs, enriches each record with firmographic data, scores the lead, and finally asks an LLM to write a personalized opening line. The result is a ready-to-export CSV (or direct CRM push) that you can use for outbound outreach without manual research.

What is AI lead generation? AI lead generation is the process of using artificial intelligence to discover, enrich, and qualify prospects automatically.


What you need

ToolPlan / Price*Role
n8n (self-hosted)Community Edition - FreeOrchestrates the entire pipeline
OpenAI GPT-4 APIPay-as-you-go (≈ $0.03 / 1 K prompt tokens, $0.06 / 1 K completion tokens)Generates icebreaker text and scoring logic
Browserless.io (headless Chrome)Free tier for low volume, paid plans start at $29/mo for 100 k runsExecutes the web-scraping steps
HubSpot CRM (Free)FreeStores enriched leads and syncs with outreach tools
Google SheetsFreeQuick view of results during development
Zapier (optional)Free tier for ≤ 100 tasks/moPushes scored leads to email outreach platforms

\*Pricing is current as of August 2026; check each provider's pricing page for the latest details.

Estimated build time: 6-8 hours for a developer comfortable with n8n and basic API usage.


Step-by-step build

1. Provision the n8n instance - Pull the Docker image: docker run -d --restart unless-stopped -p 5678:5678 n8nio/n8n - Open http://localhost:5678 and create a new workflow called Lead Enrichment + Icebreaker.

2. Add a "HTTP Request" node to fetch a prospect list - Set Method to GET. - URL: https://api.example.com/prospects?status=active (replace with your source). - Enable Pagination if the API returns paged results.

3. Split the list into individual items - Add a "SplitInBatches" node, batch size 1. This feeds each prospect into the downstream nodes one-by-one.

4. Scrape the company website for extra data - Insert a "Browserless" node (provided by the Browserless.io integration). - Endpoint: https://chrome.browserless.io/scrape - Payload (JSON):

json
 {
 "url": "{{$json[\"website\"]}}",
 "actions": [
 {
 "type": "click",
 "selector": "a[data-contact]"
 },
 {
 "type": "waitForSelector",
 "selector": ".company-info"
 },
 {
 "type": "extract",
 "selector": ".company-info",
 "property": "innerText",
 "as": "companyInfo"
 }
 ]
 }
 

What this does: Visits the prospect's website, clicks the contact link, waits for the company info block, and returns the raw text as companyInfo.

5. Enrich with third-party data (e.g., Clearbit) - Add another "HTTP Request" node. - Method: GET - URL: https://person.clearbit.com/v2/people/find?email={{$json["email"]}} - Authentication: API Key header Authorization: Bearer YOUR_CLEARBIT_KEY.

6. Score the lead - Insert a "Set" node called Score. - Add a field score with the expression:

 {{
 ($json["companyInfo"]?.includes("Fortune") ? 30 : 0) +
 ($json["clearbit"]["employment"]["title"]?.includes("CTO") ? 20 : 0) +
 ($json["openAiSentiment"]?.positive ? 10 : 0)
 }}
 

This simple rule adds points for Fortune-500 mentions, a C-level title, and a positive sentiment from the icebreaker draft (computed later).

7. Generate a personalized icebreaker - Add an "OpenAI" node (built-in in n8n). - Model: gpt-4 - Prompt (copy-paste exact):

 You are a sales writer. Write a one-sentence icebreaker for a cold email to {{ $json["firstName"] }} {{ $json["lastName"] }} at {{ $json["company"] }}. Use the following context: {{ $json["companyInfo"] }}. Keep it under 20 words and include a reference to a recent news item or product launch if possible.
 

What this does: Sends the prospect's enriched data to GPT-4, which returns a concise, context-aware opening line.

8. Store results in Google Sheets (optional for review) - Add a "Google Sheets" node, connect to a sheet named Leads. - Map columns: First Name, Last Name, Email, Company, Score, Icebreaker.

9. Push qualified leads to HubSpot - Insert a "HubSpot" node, set Operation to Create/Update Contact. - Map the same fields plus a custom property lead_score. - Enable a filter: only contacts with score >= 50 are sent.

10. Activate the workflow - Set a cron trigger to run daily at 02:00 UTC. - Turn the workflow Active.

Your pipeline now automates lead generation with AI, delivering enriched, scored contacts and a ready-to-send icebreaker without any manual copy-pasting.


Where this breaks

Failure modeSymptomsMitigation
Browserless rate limitScrape nodes start returning HTTP 429 or empty companyInfo.Upgrade to a paid plan or add a "Throttle" node limiting calls to 10 req/min.
OpenAI token quota exceeded"Insufficient quota" error from the OpenAI node.Monitor usage via the OpenAI dashboard; set a daily cap in the workflow or switch to a lower-cost model (e.g., gpt-3.5-turbo).
Clearbit API key expiry401 Unauthorized responses.Rotate the API key monthly; store the key in n8n's Credentials and enable automatic secret rotation if your vault supports it.
HubSpot field mismatchLeads are not created, error "Property does not exist".Verify custom properties (lead_score) exist in HubSpot before activation; use HubSpot's schema API to create missing fields programmatically.
Data quality gapsEmpty companyInfo leads to low scores.Add a fallback "If/Else" branch: if companyInfo missing, assign a default low score and flag for manual review.
Cost blow-upMonthly spend spikes unexpectedly.Enable n8n's built-in Execution History alerts; set a budget alarm in OpenAI and Browserless dashboards.

For a deeper technical reference, see n8n's documentation.

Frequently asked questions

How can I replace Browserless with a cheaper scraper?

You can swap the Browserless node for a simple "HTTP Request" + Cheerio transformation node if the target sites expose data in static HTML. For JavaScript-heavy pages, a headless service is still the most reliable choice.

Do I need a paid OpenAI plan to generate icebreakers?

The free trial provides limited credits; for production use you'll need a pay-as-you-go plan. The cost per icebreaker is typically under $0.001 when using `gpt-3.5-turbo`.

What if my prospect list is larger than 10 k rows per month?

n8n can handle arbitrarily large batches, but you'll need to watch API limits for each vendor. Split the list into daily chunks and use the "Cron" node to stagger execution.

Can I push leads directly to an email-automation tool instead of HubSpot?

Yes. Replace the HubSpot node with a Zapier or Make.com webhook that targets Mailshake, Lemlist, or any tool that accepts JSON payloads.

How do I keep the icebreaker tone consistent across languages?

Add a language code to the prospect record and modify the OpenAI prompt: `Write the icebreaker in {{ $json["language"] }}.` GPT-4 handles dozens of languages with similar quality. --- Ready to see the full workflow in action? Check out the Lead Enrichment Machine for a downloadable template and detailed walkthrough: https://getaab.com/vault/lead-enrichment-machine Grab the free guide to scale this

Get the full toolkit

Grab the free guide with the node-by-node build for all 10 automations.

No spam. Unsubscribe anytime. Just the good stuff.