Quick overview
This workflow captures incoming leads from an n8n Form or a webhook, uses Google Gemini to qualify and summarize them, drafts a reply email, and stores everything in n8n Data Tables, copying hot leads into a separate hot_leads table.
How it works
- Receives a new lead submission either from the n8n Form trigger or from a POST request to a webhook endpoint.
- Normalizes the incoming payload (name, email, company, budget, message, source, and timestamp) into a consistent lead record.
- Sends the lead details to Google Gemini with a structured JSON schema to classify the lead (hot/warm/cold/spam), extract key fields, and generate an email reply draft.
- Validates and merges the AI output into a final lead record, applying safe defaults and setting a suggested next step.
- Saves the completed record into the n8n Data Table named leads.
- If the lead is categorized as hot, writes the same record to a second n8n Data Table named hot_leads.
Setup
- Create two n8n Data Tables named leads and hot_leads with the required text columns (received_at, source, name, email, company, budget, message, category, service, urgency, summary, reason, reply_draft, next_step) and select them in the two Data Table nodes.
- Add a Google Gemini API credential to the Gemini chat model node (or replace it with another supported chat model and credentials).
- Update the business description and sign-off name constants in the lead-cleanup code so replies match your company.
- Publish the workflow and use the n8n Form URL or configure your source system to POST JSON to the webhook endpoint (name, email, company, budget, message, plus optional source/business/sign_off).
Requirements
- n8n with Data Tables (tested on n8n 2.48, self-hosted)
- A Google Gemini API key (the free tier works), or another chat model credential
Customization
- Change the category rules or the reply rules in the system prompt of Qualify the lead (AI)
- Swap the two Data Table nodes for Google Sheets, Airtable or your CRM
- Add an email or Slack node after Hot lead? to alert your team about hot leads
Additional info
Replies are drafts only: nothing is emailed to the lead automatically. The full project, with sample leads and a setup script, is on GitHub: github.com/mkaku2400-lang/n8n-ai-lead-inbox