An n8n agent that researches, scores and replies to every inbound lead.

Three n8n workflows that research, score and reply to every new lead, follow up after 3 days and stop when the lead replies. Demo run: a hot lead scored 94/100 and got a personal reply in 31 seconds.

Project typePersonal build, demo data
My roleDesign and build
Stackn8n, Gemini, Google Sheets, SMTP, IMAP
StatusWorking demo, self-hosted
n8n intake workflow: form, website scrape, AI scoring, Google Sheet, alert and reply
Workflow 1: Lead IntakeSimplified view, one of three workflows
Lead formn8n form or any webhook
Normalize leadClean fields, find domain, flag free email
Fetch websiteHTTP request, keeps going if it fails
Clean page textTitle, meta, first 6000 chars
Qualify with GeminiFit, budget, urgency, reasons, reply draft
Calculate scoreWeighted score and tier in code
Log to SheetEvery lead and score in Google Sheets
Alert and replyEmail alert if hot, personal reply if warm or hot
Hot: 75+, alert and replyWarm: 45 to 74, replyCold: under 45, logged as nurture, no auto reply

The problem: good leads get lost because nobody replies fast and nobody follows up.

Slow first reply

Someone has to open every form, check the company and write back. When that takes a day, the lead has often moved on.

No consistent scoring

Which lead is worth a call depends on who reads it. There is no record of why one was chased and another was not.

Follow-ups get forgotten

A lead that does not answer the first email usually gets nothing else. Nobody remembers to chase it 3 days later.

Demo run: a hot lead scored and answered in 31 seconds.

Test lead, not a client: a Shopify store asking for speed fixes before a sale. The form was submitted, the workflow read the store’s website, scored the lead and sent a personal reply.

Lead score94 / 100, hot
Fit / Budget / Urgency95 / 95 / 90
Form to reply sent31 seconds
Lead qualification result: 94 out of 100, hot lead, with fit, budget and urgency scores
Score and reasons from the demo run
Personal reply email written by AI from the lead's message and website
The reply the lead received, written from their message and website

Demo data only. No client data was used.

How it works: three workflows, one Google Sheet as the source of truth.

Lead Intake

Runs on every new lead.

  1. Capture leadn8n form or any webhook
  2. Research companyFetch and clean the lead’s website
  3. QualifyGemini returns JSON against a fixed schema
  4. Score and logCode calculates the score, row added to the Sheet
  5. ActAlert for hot leads, personal reply for warm and hot

Follow-up

Runs every day at 10 AM.

  1. Find due leadsContacted 3+ days ago, under 2 follow-ups
  2. Write follow-upGemini writes a short, specific nudge
  3. SendEmail over SMTP
  4. UpdateCount goes up, closed after the second follow-up

Reply Watcher

Watches the inbox over IMAP.

  1. New email arrivesIMAP trigger
  2. Match the senderCompare with lead emails in the Sheet
  3. Mark repliedStatus becomes replied, follow-ups stop
n8n follow-up workflow: daily trigger, due leads, AI follow-up, send and update count
Follow-up workflow in n8n

The AI gives evidence. Code decides the score.

Gemini returns three sub scores with reasons. The final number and tier are plain JavaScript in the Calculate Score node, so the same lead always gets the same score, the weights can be tuned without touching the prompt, and every score can be explained to a client.

lead_score = fit * 0.40
           + budget * 0.35
           + urgency * 0.25

-10 if free email domain and no website
-10 if 2 or more red flags

hot   >= 75
warm  45 to 74
cold  < 45  (nurture, no auto reply)

Score weights

How much each AI sub score counts toward the final lead score.

Fit with services40%
Budget signals35%
Urgency25%

From the Calculate Score node in the workflow.

Key decisions and why I made them.

AI judges only on evidence

The prompt tells the model to use only the form and the scraped website text. If the site is missing, confidence goes down instead of the model guessing.

Reusable for any agency

Services, minimum budget and sender name live in one Agency Profile node. Change those values and the same workflows work for a different business.

Follow-ups stop when the lead replies

A separate Reply Watcher marks the lead as replied, so nobody gets chased after answering. Max 2 follow-ups, then the lead is closed.

No keys in the repo

Every credential lives in n8n. The workflow JSON on GitHub has placeholders only, and the repo has demo data only.

Limits

Some websites block scraping. The flow keeps going and the AI gets “website not available”, so confidence drops.

AI scores are a first pass, not a final sales decision.

Follow-ups are new emails with a “Re:” subject over SMTP, not replies inside the same thread.

The form runs on the n8n URL. A public site needs a public n8n URL, for example a Cloudflare Tunnel or hosted n8n.

Run it yourself: setup in 7 steps.

Everything is on GitHub: the 4 workflow files, prompts, output schema and Sheet columns. The full guide is in the README.

Tech stack

n8n, self-hosted on DockerGoogle Gemini (flash lite)Google Sheets, service accountSMTPIMAPJavaScript Code nodes
  1. Google SheetCreate it and share it with your Google service account email as Editor
  2. ImportThe 4 JSON files in n8n: Workflows, Add workflow, Import from File
  3. CredentialsGoogle Service Account, Google Gemini API (free key from Google AI Studio), SMTP, IMAP
  4. PlaceholdersSheet ID, your email and name, services and minimum budget in Agency Profile, IMAP start date
  5. Run setup once00 Setup creates the Leads tab
  6. TestExecute the intake workflow and submit the test form
  7. PublishTurn on workflows 01, 02 and 03