# Qualify and route real estate leads with OpenAI and PostgreSQL: n8n workflow

> Started by another system calling it, and works across Gmail, Postgres, Slack and Twilio. It hands the judgement calls to OpenAI.

Source: https://millionrounds.com/workflow/qualify-and-route-real-estate-leads-with-openai-and-postgres (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Lead generation](https://millionrounds.com/workflows?category=Lead+generation#library)

# Qualify and route real estate leads with OpenAI and PostgreSQL

Started by another system calling it, and works across Gmail, Postgres, Slack and Twilio. It hands the judgement calls to OpenAI. 18 steps, 2 branches, 1 loop or waits: a working afternoon to understand properly.

Medium Calls a model: OpenAI

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fqualify-and-route-real-estate-leads-with-openai-and-postgres)

**18 steps** Medium: a working afternoon

**2** Branches: places the flow splits

**1** Loop or waits

**4** Services it connects to

## The flow

Starts it 3 Model 1 Logic 8 Service 6

The steps in the order they run, from what starts it.

- 1 **Receive Lead Request** Webhook *Starts it*
- 2 **Extract Lead Details** Set *Logic*
- 3 **Validate Lead Data** If *Logic*
- 4 **Save Lead in Database** Postgres *Service*
- 5 **Combine Lead + AI Data** Merge *Logic*
- 6 **Return Invalid Lead Response** Respond To Webhook *Starts it*
- 7 **AI Lead Qualification** Open Ai *Model*
- 8 **Assign Sales Agent** Code *Logic*
- 9 **Parse AI Response** Code *Logic*
- 10 **Update Lead Score** Postgres *Service*
- 11 **Check High Priority Lead** If *Logic*
- 12 **Send SMS to Lead** Twilio *Service*
- 13 **Send Confirmation Email** Gmail *Service*
- 14 **Notify Sales Team in Slack** Slack *Service*
- 15 **Prepare Reminder Data** Set *Logic*
- 16 **Return Success Response** Respond To Webhook *Starts it*
- 17 **Wait Before Follow-up** Wait *Logic*
- 18 **Send Follow-up Reminder** Gmail *Service*

## How it's built

- **Starts on:** Another system calling it
- **Steps:** 18, with 2 branches, 1 loop or waits
- **Size:** Medium: a working afternoon
- **Connects to:** Gmail, Postgres, Slack, Twilio
- **Model:** OpenAI

## Questions

What does it need to run?

An n8n account, plus your own Gmail, Postgres, Slack and Twilio accounts, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on another system calling it.

Does it use AI?

Yes. It calls OpenAI. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Plan an afternoon. 18 steps is enough that you should read each one before running it.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 18 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fqualify-and-route-real-estate-leads-with-openai-and-postgres)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Gmail](https://millionrounds.com/workflows?service=Gmail#library)[Postgres](https://millionrounds.com/workflows?service=Postgres#library)[Slack](https://millionrounds.com/workflows?service=Slack#library)[Twilio](https://millionrounds.com/workflows?service=Twilio#library)

## Workflows like it

Also lead generation, with the same services where possible, closest in size first.

- [**AI lead gen & personalized email agent with Sheets and Apify** 18 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/ai-lead-gen-and-personalized-email-agent-with-sheets-and-api)
- [**Automate B2B lead generation & personalized cold emails** 18 steps · calls a model · Email, Gmail](https://millionrounds.com/workflow/automate-b2b-lead-generation-and-personalized-cold-emails)
- [**Automate cold outreach with Apollo and LinkedIn** 18 steps · calls a model · Gmail, HubSpot](https://millionrounds.com/workflow/automate-cold-outreach-with-apollo-and-linkedin)
- [**Automated lead capture & AI-personalized audio follow-up** 18 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/automated-lead-capture-and-ai-personalized-audio-follow-up)
- [**Create AI personalized video & voice outreach with HeyGen** 18 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/create-ai-personalized-video-and-voice-outreach-with-heygen)
- [**Generate sales leads from Indeed jobs with BrightData** 18 steps · calls a model · Gmail](https://millionrounds.com/workflow/generate-sales-leads-from-indeed-jobs-with-brightdata)
