Automation Project

AI-Powered Lead Qualification
& CRM Automation

A fully automated workflow that captures website leads, validates requests, scores them with Gemini AI, creates CRM pipeline deals, and prepares personalized follow-up drafts — all without manual intervention.

TypeAutomation System
RoleFull-Stack Developer
StatusCompleted
n8nSupabaseGemini APINext.jsREST APIWebhooks

/problem

Businesses often receive leads from multiple sources — websites, social media, referrals — but struggle with slow follow-ups, inconsistent qualification, duplicate submissions, and unclear lead priority. Without a structured process, high-value leads get lost, teams waste time on low-intent contacts, and there's no clear system for deciding who to follow up with first.

/solution

I built an automated lead qualification workflow that handles everything from initial capture to CRM entry:

  • 01

    Receives leads from a secure webhook endpoint

  • 02

    Validates each request using a shared-secret header

  • 03

    Normalizes lead data into a consistent schema regardless of source

  • 04

    Checks for duplicate submissions via Supabase before processing

  • 05

    Stores raw webhook events and normalized leads with full metadata

  • 06

    Uses Gemini API to analyze lead quality, intent, and pain points

  • 07

    Calculates a composite lead score across multiple weighted dimensions

  • 08

    Creates a deal record in the CRM pipeline automatically

  • 09

    Prepares a personalized follow-up email draft ready for human approval

  • 10

    Logs the full automation lifecycle end-to-end for traceability

/system architecture

01
Lead Source
Website form, social, referral
02
Secure Webhook
Shared-secret header validation
03
Duplicate Check
Email lookup in Supabase
04
Normalize Payload
Consistent internal schema
05
Save Raw Event + Lead
Immutable audit record
06
Gemini Enrichment
Pain points, risk, service fit
07
Business Rule Scoring
Budget, urgency, quality, fit
08
CRM Deal Creation
Pipeline stage + AI data attached
09
Follow-Up Draft
AI-written, queued for approval
10
Slack Alert + Audit Log
Team notified, lifecycle logged

Each step is an isolated n8n node. If any stage fails — duplicate detected, invalid secret, Gemini timeout — the pipeline halts cleanly and logs the failure without affecting other leads.

The full pipeline runs in under three seconds from webhook trigger to CRM entry, Slack alert, and approval request.

/connected systems

8 INTEGRATIONS ACTIVE
ALL CONNECTED
Website / Next.js Form
Lead capture entry point
n8n Workflow Engine
Automation orchestration
Gemini API
AI qualification & scoring
Supabase Database
Lead storage & event logging
Slack
Hot & warm lead alerts
CRM Pipeline Tables
Deal record creation
Approval Request Queue
Human-in-the-loop email review
Automation Logs
End-to-end lifecycle traceability

/interactive demo

Submit a sample lead and see the AI qualification result. No external API calls are made — this uses static pre-generated output.

SAMPLE LEAD INPUT
Full Name
Michael Harris
Email
michael@example.com
Phone
+1 555 123 4567
Company
Harris Home Services
Service Type
Website + Automation
Budget
$5,500
Location
Austin, Texas
Urgency
ASAP
Message

We get Facebook leads but our team keeps missing follow-ups. We need a website and automation system that helps us respond faster.

For security and cost control, this public demo uses sample AI output. A live backend walkthrough is available upon request.

/key features

01

Secure Webhook Validation

Request headers are verified with a shared secret before any processing begins.

02

Multi-Source Lead Normalization

Incoming data from any source is standardized to a consistent internal schema.

03

Duplicate Detection

Email-based lookup in Supabase prevents re-processing the same lead twice.

04

Gemini-Powered Qualification

AI analyzes lead messages and context to determine intent and overall quality.

05

AI Scoring Breakdown

Budget, urgency, service fit, and message quality scored as separate dimensions.

06

Supabase Persistence

Raw webhook events and normalized leads stored with timestamps and metadata.

07

CRM Pipeline Automation

Deal records are created automatically with AI-enriched lead data attached.

08

Follow-up Email Draft Generation

AI writes a personalized draft ready for human review before sending.

09

Workflow Logging & Traceability

Every step of the automation lifecycle is logged for debugging and auditing.

/technical implementation

The backend is built entirely inside n8n, using a combination of webhook nodes, HTTP nodes, code nodes, and Supabase integrations. Here's how each stage works:

01 — Webhook Trigger

n8n receives an HTTP POST to a secure endpoint. A shared-secret header is validated before any action is taken.

02 — Duplicate Check

A Supabase lookup verifies the submitted email does not already exist in the leads table. Duplicate submissions are rejected early.

03 — Raw Event Storage

The raw payload is saved to a webhook_events table before any transformation, preserving the original data for auditing.

04 — Gemini Analysis

The lead message, service type, and urgency are sent to Gemini with a structured prompt. The model returns a JSON object with pain points, risk level, and recommendations.

05 — Score Calculation

A code node parses the AI response and computes a composite score using budget, urgency, service fit, message quality, location, and AI confidence.

06 — CRM Deal Creation

A normalized deal record is written to the crm_deals table in Supabase, including the AI score, category, and enrichment data.

07 — Email Draft Approval

An approval request is created in n8n containing the AI-generated follow-up email. A team member reviews and sends — or discards — the draft.

/human-in-the-loop

The system does not automatically send important sales replies.

Instead, it creates an approval request so a human can review, edit, approve, or reject the AI-generated draft before anything is sent. The AI handles research, scoring, and writing — but a real person makes the final call on every outbound message.

APPROVAL WORKFLOW
AI

Analyzes the lead, scores it, and writes a personalized follow-up draft

n8n

Creates an approval request containing the draft, lead score, and AI summary

Human

Reviews the draft — edits the tone, adjusts the copy, or rejects it entirely

Human

Approves — the email is sent. Or rejects — the draft is discarded with no action taken

System

Logs the approval decision and outcome to the automation audit trail

/how this system can be adapted to gohighlevel and slack

This workflow can be connected to GoHighLevel through webhooks or API-based contact and deal creation. Instead of storing deals only in Supabase, the same lead score, AI summary, and follow-up recommendation can be pushed directly into a GoHighLevel pipeline — creating contacts, tagging leads by tier, and triggering GHL automations based on the AI score. Internal notifications can also be sent to Slack whenever a hot or warm lead is detected, so your team knows immediately without checking a dashboard.

SAMPLE SLACK NOTIFICATIONSlack lead notification

/screenshots

/results & business value

BEFORE
AFTERTHIS SYSTEM

Leads arrived from different sources in inconsistent formats

Every lead is normalized to a consistent schema regardless of source

No duplicate check — the same contact could enter the pipeline multiple times

Duplicate submissions are caught at intake before any processing happens

Qualification was manual, slow, and inconsistent across team members

AI scores each lead across budget, urgency, fit, and message quality within seconds

High-value leads had no priority signal — they sat in the same inbox as low-intent submissions

High-score leads are flagged immediately with a numeric tier and recommended next action

Follow-up depended entirely on someone remembering to act

A personalized follow-up draft is generated and queued for human approval automatically

No audit trail — if a lead was missed, there was no record of why

Every step of the automation lifecycle is logged and fully auditable end-to-end

Want a system like this
for your business?

I build custom automation workflows tailored to your lead sources, CRM, and follow-up process. Get in touch for a free discovery call.