B2B Lead Qualification & Follow-up Automation
Capture, score, route and follow up on inbound leads without manual triage.
- Workflow orchestration
- HubSpot
- OpenAI API
- PostgreSQL
- Gmail API
Overview
A complete inbound lead pipeline designed around one constraint: every lead gets a consistent decision and a reply within minutes, and every decision is explainable afterwards.
The problem
Inbound leads arrive through forms and inboxes, then wait for someone to read, judge and forward them. Response times slip and qualification is inconsistent between people and days.
Existing process
- 01Lead submits a website form; a notification email lands in a shared inbox.
- 02Someone reads the message, guesses fit, and copies fields into the CRM by hand.
- 03The lead is forwarded to a rep over chat, sometimes with context, sometimes without.
- 04Follow-up depends on whoever remembers; no shared definition of a qualified lead.
Proposed system
- Single intake endpoint normalises every source into one lead schema.
- Deterministic validation runs before any AI: email syntax, domain checks, duplicate lookup.
- An LLM step returns a strict JSON verdict — segment, fit score, reasoning, next action.
- CRM record is created or merged idempotently using the email domain as the merge key.
- Routing rules assign an owner by segment and territory, with a fallback queue.
- A templated first-touch email is generated, then queued for send with a human-review gate on low-confidence leads.
The system, node by node
- 01
Form intake
Webhook receives payload, stamps source + timestamp
- 02
Validation
Schema check, disposable-domain filter, dedupe lookup
- 03
Enrichment
Company domain metadata attached to the record
- 04
AI qualification
Structured JSON: score, segment, reasoning
- 05
CRM sync
Upsert contact + company, write score fields
- 06
Routing
Owner assignment by segment, territory and load
- 07
Follow-up
Personalised first-touch email, review gate under threshold
- 08
Reporting
Daily rollup: volume, score distribution, response time
- Form intake
- Validation
- Enrichment
- AI qualification
- CRM sync
- Routing
- Follow-up
- Reporting
Business logic
- Score >= 70
- Route to sales owner immediately, send first-touch email automatically.
- Score 40–69
- Route to nurture sequence, notify owner without an SLA clock.
- Score < 40
- Store in CRM, no outreach, included in the weekly review sample.
- Confidence < 0.6
- Hold outbound email and flag the lead for human review.
- Existing open deal
- Never create a duplicate; append the message to the deal timeline.
Failure handling
- CRM API timeout
- Exponential backoff, three retries, then a dead-letter table with alert.
- Invalid or partial payload
- Rejected at the schema gate, stored raw for inspection, never silently dropped.
- Duplicate submission
- Idempotency key on email + form + 10-minute window.
- LLM returns malformed JSON
- One reparse attempt with a stricter prompt, then fall back to rule-based scoring.
- Ambiguous fit
- Escalated to a human review queue rather than guessed.
Demonstration
Simulation notice
This project is a portfolio simulation built to demonstrate automation architecture and workflow implementation. It was exercised against a generated dataset of synthetic leads to test routing, deduplication and failure paths — the figures below describe the simulation, not a client deployment.
Design decisions
Validate before you spend a token
Deterministic checks run first. Junk never reaches the model, which keeps cost predictable and makes failures easier to read.
Structured output, not prose
The model returns a strict schema. Anything that fails the schema falls back to rules instead of half-parsing free text.
Idempotency is the whole game
Retries are only safe when every write is keyed. Most of the design time went into merge keys, not into the happy path.
Want a process mapped like this?
Contact Me