Makani Tech: Build. Automate. Evolve.

Real Estate Leads to Site Visits with n8n + OpenAI (free workflow)

Every property lead from your website, ads, portals and WhatsApp is scored by OpenAI, followed up on WhatsApp for 21 days and booked into a site visit slot from Google Calendar, with a PostgreSQL CRM behind it.

FreeWorkflowBy Kishan Makani · updated 5 November 2026 · 10 min read

PostgreSQLOpenAIWhatsApp Business CloudGoogle CalendarGmailFacebook Lead Ads

Downloads

  • Download the n8n workflow (JSON)

    real-estate-lead-to-site-visit-n8n-openai.json · n8n workflow · 50 steps · starts with New Lead Webhook · uses Facebook Lead Ads, WhatsApp, PostgreSQL, OpenAI, Google Calendar, Gmail · 94 KB

  • Download the PostgreSQL schema (SQL)

    schema.sql.txt · 80 KB

    Run once on your PostgreSQL database before the first test: psql "$DATABASE_URL" -f schema.sql.txt

How to import it into n8n
  1. In n8n, create a new workflow.
  2. Open the ⋯ menu at the top right and choose Import from File, then pick the downloaded .json. (Or open the file, copy everything and paste it on the canvas.)
  3. Open each node with a warning and connect your own account: the file carries no passwords or keys.
  4. Run it once with Test workflow, check the result, then switch it to Active.

What this workflow does

Turn every property enquiry into a scored lead, a 21-day WhatsApp follow-up and a booked site visit, without a sales assistant doing it by hand. Leads from your website, Facebook and Instagram Lead Ads, Google Ads lead forms, portals, walk-ins and WhatsApp land in one PostgreSQL CRM with duplicates merged. OpenAI scores each lead from facts only, the right executive gets it, and approved WhatsApp templates go out on schedule. Customer replies are read by OpenAI: visit requests get real free slots from Google Calendar, everything else goes to a person.

  1. Eight triggers (New Lead Webhook, Facebook Lead Ads, Manual Lead Entry Form, WhatsApp Messages, Sales Update Form, Every Minute, Every Morning at 9, When Workflow Fails) all pass through Workflow Configuration, and Route by Trigger sends each run to its section.
  2. Normalize Lead Fields maps every source to one lead format and checks the phone and intake key. Save Lead and Check Duplicates writes the lead in PostgreSQL. A repeated event is ignored and a known phone updates the same lead.
  3. Score Lead with OpenAI returns a score, confidence, missing facts and a short summary. Save Score and Start Follow-up picks the hot, warm or nurture sequence, assigns the executive with the fewest open leads and saves every step as a row in the follow-up queue.
  4. Every Minute runs Claim Due Follow-ups, which picks due rows, skips the ones that no longer apply and respects quiet hours. Send WhatsApp Message, Email Sales Team, Delete Old Calendar Event and Sync Stage to CRM do the work and Record Send Result marks each row sent or schedules a retry.
  5. WhatsApp Messages feeds Log Inbound Message, which logs each message once and handles STOP and START. Classify Reply with OpenAI reads the reply. Act on Reply Intent stops nudges, alerts the executive, or asks for slots.
  6. Get Executive Calendar and Find Free Visit Slots pick three free times. The customer replies 1, 2 or 3, Book Picked Slot books it (the database blocks double booking), Create Visit in Calendar adds the event and Confirm Visit and Queue Reminders queues the confirmation and the 24 hour and 2 hour reminders.
  7. Sales Update Form lets the team record visit outcome, negotiation, WON (deal value and booking date required) and LOST (reason required).
  8. Every Morning at 9 emails management yesterday's numbers. When Workflow Fails logs errors in Postgres and emails the admin.

Who it is for

Real estate developers, builders, brokers and channel partners who get leads from many sources and lose them because nobody follows up on time. Works for any team that sells through site visits (plots, villas, apartments, commercial space).

What you need

  • n8n (Cloud or self-hosted)
  • PostgreSQL database
  • OpenAI API key
  • WhatsApp Business Platform (Cloud API) number with approved templates
  • Google Calendar per sales executive (or one shared calendar)
  • Gmail account for team emails
  • Optional: Facebook Lead Ads page access, Google Ads lead form webhook, any CRM with a webhook

The workflow, step by step

Step 1 · Lead sources and routing

Eight entry points share one Workflow Configuration. Route by Trigger sends each run to its section.

  • New Lead Webhook (Webhook)
  • Facebook Lead Ads (facebookLeadAdsTrigger)
  • Manual Lead Entry Form (n8n Form)
  • WhatsApp Messages (WhatsApp Trigger)
  • Sales Update Form (n8n Form)
  • Every Minute (Schedule)
  • Every Morning at 9 (Schedule)
  • When Workflow Fails (Error Trigger)
  • Workflow Configuration (Set)
  • Route by Trigger (Switch)

Step 2 · Capture and dedupe

Maps every source to one lead format and checks the phone and intake key. A repeated event is ignored and a known phone updates the same lead.

  • Normalize Lead Fields (Code)
  • Is Lead Valid? (IF)
  • Save Lead and Check Duplicates (postgres)
  • Log Rejected Lead (postgres)

Step 3 · AI qualification

OpenAI scores the lead 0-100 from facts only. 70+ is hot, 40-69 warm, below 40 nurture. The score picks the sequence and the sales executive.

  • Needs Qualification? (IF)
  • OpenAI Scoring Model (lmChatOpenAi)
  • Score Lead with OpenAI (Basic LLM Chain)
  • Lead Score Parser (Structured Output Parser)
  • Use Neutral Score (Set)
  • Save Score and Start Follow-up (postgres)

Step 4 · WhatsApp replies

Logs each message once and handles STOP and START. OpenAI reads what the customer wants; questions, price talk and "not interested" go to the executive.

  • Read WhatsApp Event (Code)
  • Log Inbound Message (postgres)
  • Route Inbound Message (Switch)
  • OpenAI Reply Model (lmChatOpenAi)
  • Classify Reply with OpenAI (Basic LLM Chain)
  • Reply Intent Parser (Structured Output Parser)
  • Send Reply to Sales Team (Set)
  • Act on Reply Intent (postgres)
  • Wants a Site Visit? (IF)

Step 5 · Site visit booking

Offers free slots from the executive's Google Calendar. The customer replies with a number, the database blocks double booking and reminders are queued.

  • Book Picked Slot (postgres)
  • Slot Still Free? (IF)
  • Create Visit in Calendar (Google Calendar)
  • Confirm Visit and Queue Reminders (postgres)
  • Get Executive Calendar (Google Calendar)
  • Find Free Visit Slots (Code)
  • Send Slot Options (postgres)

Step 6 · Follow-up dispatcher

Every minute sends due rows from the queue. Replied, booked, opted-out and closed leads are skipped. Failures retry with growing delays.

  • Claim Due Follow-ups (postgres)
  • Route by Action (Switch)
  • Send WhatsApp Message (HTTP Request)
  • Email Sales Team (Gmail)
  • Delete Old Calendar Event (Google Calendar)
  • Sync Stage to CRM (HTTP Request)
  • Record Send Result (postgres)

Step 7 · Sales team updates

A person sets visit outcome, negotiation, won and lost. Lost needs a reason, won needs the deal value.

  • Apply Sales Update (postgres)
  • Show Update Result (form)

Step 8 · Daily report

Emails yesterday's leads, visits, no-shows, deals, revenue and lost reasons.

  • Get Yesterday's Numbers (postgres)
  • Format Daily Report (Code)
  • Email Daily Report (Gmail)

Step 9 · Error alerts

A failed run is saved in Postgres and emailed to the admin.

  • Log Workflow Error (postgres)
  • Alert Admin About Failure (Gmail)

Setup

  1. Download the JSON below and import it in n8n (Create workflow > ⋯ > Import from File).
  2. Run schema.sql on a PostgreSQL 13+ database (Supabase, Neon, RDS or your own server). Replace the sample executives and the sample project with yours.
  3. Add credentials: Postgres, OpenAI, WhatsApp API (send) and WhatsApp OAuth (trigger), Google Calendar, Gmail, Facebook Lead Ads, Basic Auth for the two forms, and optionally a Header Auth credential for your CRM.
  4. Create the 17 WhatsApp templates named in the sequence_steps table (sample texts below) in WhatsApp Manager and wait for approval.
  5. Open Workflow Configuration and set companyName, whatsappPhoneNumberId, intakeSecret, managementEmail, adminAlertEmail, timezone, score thresholds, quiet hours and visit hours.
  6. Point your website form, Google Ads lead form webhook and portal integrations at the New Lead Webhook URL with the header x-intake-key.
  7. Send a test lead, check the leads and followup_queue tables, then activate.
  8. Test it: POST {"name":"Rahul Sharma","phone":"9876543210","project":"Green Meadows","budget":"80 lakh","consent":true} with header x-intake-key. Expected: a scored row in leads and the welcome WhatsApp within a minute.

How to customise

The sample prompts and messages are a starting point, not a fixed format. - Score Lead with OpenAI, Classify Reply with OpenAI: edit the prompts, rubric and intents - sequence_steps table: change timing, templates, email text, or add a sequence - Manual Lead Entry Form, Sales Update Form: add or remove fields - Every Minute, Every Morning at 9: change the schedules - highScoreMin, mediumScoreMin, replyMinConfidence: change the thresholds - visitDays, visitStartHour, visitEndHour, visitMinutes, slotsToOffer: change site visit hours - crmSyncEnabled and crmWebhookUrl: send every stage change to HubSpot, Zoho, Salesforce or your own CRM

Why OpenAI

OpenAI gpt-5.4-mini on both AI steps. Both jobs are short structured classification tasks (score a lead, read a WhatsApp reply), so a small fast model is the right fit: it costs a fraction of a cent per lead, answers in about a second, and follows a strict JSON schema reliably. Temperature is 0.1 for scoring and 0 for reply reading so the same input gives the same answer. The prompts tell the model to use only facts in the lead and never guess a budget, timeline or date, and both chains have a fallback: if OpenAI fails, the lead gets a neutral score of 50 with confidence 0, and an unreadable reply goes to the executive. Swap the model in OpenAI Scoring Model and OpenAI Reply Model if you want a larger one.

WhatsApp templates to create

Create these in WhatsApp Manager with the language in whatsappTemplateLanguage. The variables must be in this order, because the dispatcher fills {{1}}, {{2}}... from body_params in sequence_steps. Use category Marketing for promotional ones and Utility for visit messages. The texts are suggestions; Meta may ask you to change the wording.

Template Category Header Body
re_welcome Marketing none Hi {{1}}, thanks for your interest in {{2}}. I am {{3}} and I will help you with prices, floor plans and a site visit. What kind of home are you looking for? Reply STOP to opt out.
re_followup_nudge Marketing none Hi {{1}}, just checking you got my message. {{2}} here, happy to answer any question about the project.
re_followup_day1 Marketing none Hi {{1}}, would you like the latest price list and available units at {{2}}? Reply YES and I will send them.
re_media_floorplan Marketing Image Hi {{1}}, here is the floor plan for {{2}}. Brochure: {{3}} Video walkthrough: {{4}}
re_project_benefits Marketing none {{1}}, a few reasons families choose {{2}}: {{3}} Location: {{4}}
re_requirements_check Marketing none Hi {{1}}, to suggest the right unit, could you share your budget, preferred size and when you plan to move?
re_site_visit_invite Marketing none Hi {{1}}, seeing {{2}} in person is the best way to decide. Would you like to book a free site visit? Reply VISIT and a day that suits you.
re_objection_help Marketing none Hi {{1}}, if anything is holding you back on {{2}} (budget, loan, location or possession date), tell me and I will find an option for you.
re_active_followup Marketing none Hi {{1}}, {{2}} here. Are you still looking for a home? I can share new offers whenever you are ready.
re_longterm_update Marketing none Hi {{1}}, I will stop the regular updates on {{2}} for now. Message us anytime if you want details or a site visit.
re_nurture_checkin Marketing none Hi {{1}}, there is news on {{2}} and our new projects. Would you like an update?
re_visit_confirmed Utility none Hi {{1}}, your site visit at {{2}} is confirmed for {{3}} at {{4}}. Location: {{5}} Your contact: {{6}}, {{7}}.
re_visit_reminder_24h Utility none Hi {{1}}, a reminder of your site visit at {{2}} tomorrow at {{3}}. Location: {{4}} Reply CHANGE if you need another time.
re_visit_reminder_2h Utility none Hi {{1}}, see you at {{2}} today. Address: {{3}} Call {{4}} if you need directions.
re_visit_noshow Utility none Hi {{1}}, we missed you at {{2}} today. No problem, would you like to pick another time for your visit?
re_visit_feedback Utility none Hi {{1}}, thank you for visiting {{2}} today. How did you like it? Any questions I can answer?
re_project_details Utility Image Hi {{1}}, here are the details for {{2}}. Brochure: {{3}} Location: {{4}}

The two templates with an image header use the project's floor_plan_image_url, which must be a public HTTPS image. Slot offers, the cancel confirmation and the opt-out confirmation are plain text messages, which WhatsApp allows only within 24 hours of the customer's last message. They are always replies, so they are inside that window, and the dispatcher skips any that are not.

Guardrails

  • Approved templates only: Every template name in sequence_steps must be approved in WhatsApp Manager with the same number of variables, or Meta rejects the message.

Troubleshooting

  • Credential errors after import: imported workflows never include credentials. Open each node marked red and select your own account.
  • Nothing runs on its own: test runs only fire once. Activate the workflow so the trigger keeps running.
  • Odd times or dates: set your timezone in Workflow Settings.

Want the members-only resources too?

A free account unlocks them all, including the ones shared in DMs.

Create a free account