Templates / Qualify B2B leads with OpenAI, PostgreSQL, and human email approval

Qualify B2B leads with OpenAI, PostgreSQL, and human email approval

Ready for 3.0

by Paras Gediya ✓ · 28 views · created 2026-09-12 · Lead Generation, AI Chatbot

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

What this workflow does

This AI workflow has 42 nodes and runs manually, when you click “Execute workflow” (plus 1 other trigger). Along the way it connects Postgres, OpenAI Chat Model and Postgres Chat Memory.

How it runs

Trigger: Manually, when you click “Execute workflow” (plus 1 other trigger).

  1. Create Agent Tables (Postgres): run a query
  2. Workflow Configuration (Edit Fields (Set)): sets 11 fields: business_name, services, from_name…
  3. Normalize Lead (Code): runs custom JavaScript code
  4. Validate Lead (Code): runs custom JavaScript code
  5. Valid Lead? (If): checks a condition and branches into true / false
  6. Upsert Lead (Postgres): run a query
  7. Return Invalid Lead (Respond to Webhook): sends the response back to the webhook caller
  8. Hybrid Lead Qualification Agent (AI Agent): runs an AI agent, with model: OpenAI Chat Model; 4 tools (Log Lead Activity, Look Up Lead History, Save Agent Assessment, Lead Policy Calculator); memory: Postgres Lead Memory; output parser: Structured Lead Decision
  9. Normalize Agent Decision (Code): runs custom JavaScript code
  10. Agent Decision Valid? (If): checks a condition and branches into true / false

…plus 18 more steps. See the full node list below.

Services it uses

PostgresOpenAI Chat ModelPostgres Chat Memory

Before you upgrade to n8n 3.0

Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.

Nodes used (15)

From the author

Quick overview This workflow receives B2B lead submissions via webhook, stores them in PostgreSQL, and uses an OpenAI-powered n8n AI Agent with Postgres-backed memory to score and draft next steps. It routes low-confidence outputs to manual review and…

Excerpt from Paras Gediya's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.