Qualify B2B leads with OpenAI, PostgreSQL, and human email approval
Ready for 3.0What 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).
- Create Agent Tables (Postgres): run a query
- Workflow Configuration (Edit Fields (Set)): sets 11 fields: business_name, services, from_name…
- Normalize Lead (Code): runs custom JavaScript code
- Validate Lead (Code): runs custom JavaScript code
- Valid Lead? (If): checks a condition and branches into true / false
- Upsert Lead (Postgres): run a query
- Return Invalid Lead (Respond to Webhook): sends the response back to the webhook caller
- 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
- Normalize Agent Decision (Code): runs custom JavaScript code
- 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
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)
- Manual Trigger
n8n-nodes-base.manualTrigger - Postgres
n8n-nodes-base.postgres - No Operation, do nothing
n8n-nodes-base.noOp - Webhook
n8n-nodes-base.webhook - Edit Fields (Set)
n8n-nodes-base.set - Code
n8n-nodes-base.code - If
n8n-nodes-base.if - Respond to Webhook
n8n-nodes-base.respondToWebhook - AI Agent
@n8n/n8n-nodes-langchain.agent - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Postgres Chat Memory
@n8n/n8n-nodes-langchain.memoryPostgresChat - Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured - Postgres Tool
n8n-nodes-base.postgresTool - Code Tool
@n8n/n8n-nodes-langchain.toolCode - Send Email
n8n-nodes-base.emailSend
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…