Sales Automation
lead generation
How to Build an AI Lead Enrichment Pipeline
Automatically enrich leads with company data, social profiles, and tech stack info.
Jay Banlasan
The AI Systems Guy
I set up this system to automatically enrich leads with company data, social profiles, and tech stack info. This ai lead enrichment data pipeline automated approach turns manual lead work into automated pipeline growth.
Lead generation is the lifeblood of the business. Automating it means your pipeline fills while you focus on closing.
What You Need Before Starting
- Python 3.8+ with requests
- Anthropic API key
- CRM API (HubSpot, GoHighLevel, or similar)
- Database for lead storage
Step 1: Build the Capture Layer
from flask import Flask, request
import sqlite3
from datetime import datetime
app = Flask(__name__)
db = sqlite3.connect("leads.db")
db.execute('''CREATE TABLE IF NOT EXISTS leads (
id INTEGER PRIMARY KEY AUTOINCREMENT,
email TEXT UNIQUE, name TEXT, source TEXT,
score INTEGER DEFAULT 0, created_at TEXT, status TEXT DEFAULT 'new'
)''')
@app.route("/api/lead", methods=["POST"])
def capture():
data = request.json
db.execute("INSERT OR IGNORE INTO leads (email, name, source, created_at) VALUES (?,?,?,?)",
(data["email"], data.get("name", ""), data.get("source", "direct"), datetime.now().isoformat()))
db.commit()
return {"status": "captured"}
Step 2: Qualify with AI
import anthropic
from dotenv import load_dotenv
load_dotenv()
client = anthropic.Anthropic()
def qualify_lead(lead):
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=256,
system="Score this lead 1-100. Consider source, engagement, fit. Classify hot/warm/cold.",
messages=[{"role": "user", "content": f"Lead: {lead}. Score and classify."}]
)
return message.content[0].text
Step 3: Route to Right Sequence
def route_lead(lead, score):
if score >= 80:
trigger_hot_sequence(lead)
notify_sales(lead)
elif score >= 50:
trigger_nurture(lead)
else:
add_to_long_term(lead)
Step 4: Sync to CRM
import requests
def push_to_crm(lead, api_key):
return requests.post(
"https://api.hubapi.com/crm/v3/objects/contacts",
headers={"Authorization": f"Bearer {api_key}"},
json={"properties": {"email": lead["email"], "firstname": lead["name"], "lead_score": str(lead["score"])}}
).json()
What to Build Next
Add multi-touch attribution to know which channels produce highest-quality leads, not just the most volume.
Related Reading
- Building Automated Data Enrichment Pipelines - framework for deciding what to automate first
- How to Use AI for Data Enrichment - building data infrastructure for AI operations
- The Data Flywheel Explained - building data infrastructure for AI operations
Want this system built for your business?
Get a free assessment. We will map every system your business needs and show you the ROI.
Get Your Free Assessment