Screenshot 2026-11-25 213104.png

Built by: Mark Geoffrey A. Batocabe, GHL Automation Specialist Stack: n8n Cloud · Google Gemini API · Google Sheets · Gmail · Slack · JavaScript Demo video: https://www.loom.com/share/24af0dc8fef441d68d45a5893f466681 - https://www.loom.com/share/4f0e3ddc5e8546c6b34ee79b85275996


Overview

An AI-powered lead qualification system that scores every inbound lead, writes a personalized follow-up email, and alerts the sales team on Slack, in about 30 seconds and with no manual work.

The problem: Small businesses receive inquiries from forms, but they reply slowly and can't tell serious clients from spam, job seekers, or vendors. Hot leads go cold while they wait.

The solution: Every form submission is deduplicated, enriched with the lead's website content, and analyzed by Gemini. Hot leads instantly get a personalized email draft and a Slack alert. Every lead, including spam, is logged to a CRM with a score and the AI's reasoning.

Results at a glance

Metric Result
Time from form submit to Slack alert ~30 seconds
Test scenarios passed 10 / 10
Prompt injection attempt Blocked (scored 0, flagged as spam)
Leads lost when the AI or a website fails 0 (fallback to needs_review)
AI emails sent without human review 0 (drafts only)

How it works

  1. Intake & Dedupe. An n8n Form captures the lead. The data is normalized (trimmed, lowercased email, website URL fixed) and checked against the CRM so the same person is never contacted twice.
  2. Website Enrichment. If the lead gave a website, the workflow fetches it, strips the HTML, and keeps the first 3,000 characters as context. If the site is down, the workflow continues and records fetch_failed.
  3. AI Scoring. Gemini analyzes the lead and returns structured JSON: score (0-100), spam flag, intent, industry, budget signal, a one-line summary, reasoning, and personalization hooks. JavaScript validates the output and assigns the tier.
  4. Log & Route. Every lead is written to a Google Sheets CRM first, then routed by tier.
  5. Actions. Hot leads get a personalized email written by a second Gemini call, saved as a Gmail draft, plus a Slack alert. If the AI fails, the lead is marked needs_review and the team is alerted.
Tier Rule What happens
Hot Score 70+ CRM row, AI-written Gmail draft, Slack alert
Warm Score 40-69 CRM row, status nurture
Cold Score below 40 CRM row, status no_action
Spam AI flags spam CRM row, status spam
Needs review AI call failed CRM row and Slack review alert

Screenshot 2026-11-25 213319.png

Key design decisions

1. Structured output with responseSchema

Gemini is given an exact JSON schema with field types and allowed values. The API enforces the format, so downstream nodes never break on malformed or chatty AI responses.