Qualify and route client leads with OpenAI, Supabase, and Gmail

Go to Workflow
0 views
Built by Muhammad Bilal Muhammad Bilal
Created on August 27, 2026

Description

Quick overview
This workflow captures client requests via an n8n Form, validates and stores leads in Supabase, uses OpenAI to generate a structured requirements analysis, then calculates a rule-based qualification score and sends the appropriate client and internal emails through Gmail for HOT, WARM, or LOW-FIT leads.

How it works
Receives a new submission from an n8n Form with project, budget, timeline, and contact details.
Normalizes the form fields and checks that required information (including a valid email and minimum brief length) is present.
If required details are missing, compiles a list of issues and sends a clarification request to the client via Gmail.
If the submission is valid, creates a new lead record in Supabase.
Sends the lead details to OpenAI to produce a structured summary, risk flags, missing information, and a recommended next step.
Computes a deterministic qualification score from the lead data and AI outputs, then routes the lead as HOT, WARM, or LOW-FIT.
Updates the lead in Supabase and sends the matching client email plus an internal team notification via Gmail, then marks the lead status as contacted/sent.

Setup
Add a Supabase credential and ensure a leads table exists with fields used by the workflow (for example: full_name, email, company_name, industry, required_service, project_brief, budget_range, expected_timeline, phone_number, lead_status, and the AI/score fields).
Add an OpenAI API credential for the OpenAI node and select/confirm a structured-output capable model.
Add a Gmail OAuth2 credential for the Gmail send steps.
Replace [email protected] with your real internal notification address in the team email steps.
Customize the n8n Form title/description/fields and update the email templates (agency name and wording) to match your process before activating the workflow.

Requirements
OpenAI API credential, Supabase project/table, Gmail credential, and an n8n Form Trigger setup.

Customization
Update lead scoring rules, email wording, Supabase field names, and internal notification address to match your agency process.

Nodes Used (4)

Code
n8n-nodes-base.code
Gmail
n8n-nodes-base.gmail
OpenAI
@n8n/n8n-nodes-langchain.openAi
Supabase
n8n-nodes-base.supabase