How to Build an AI Voice Agent for Real Estate Lead Automation with n8n (Free Template)

How to Build an AI Voice Agent for Real Estate Lead Automation with n8n (Free Template)

Real estate agents spend 60-70% of their time on repetitive tasks: answering the same property questions, qualifying leads, and scheduling showings. An AI voice agent handles these conversations automatically, 24/7, while you focus on closing deals. This guide shows you how to build a production-ready real estate voice agent using n8n that qualifies leads, answers property inquiries, and books appointments directly into your calendar.

The Problem: Real Estate Lead Response Time Kills Conversions

Current challenges:

  • Leads call outside business hours and get voicemail instead of answers
  • Agents waste 15-20 hours per week answering basic property questions
  • Follow-up calls slip through the cracks during busy showing schedules
  • Manual lead qualification delays response time by 24-48 hours
  • Appointment scheduling requires 3-5 back-and-forth messages per lead

Business impact:

  • Time spent: 20+ hours per week on repetitive phone conversations
  • Conversion loss: 35-50% of leads go cold due to slow response times
  • Revenue impact: Each missed lead costs $3,000-$8,000 in potential commission
  • Agent burnout: Constant interruptions prevent focus on high-value activities

Real estate operates on speed. The first agent to respond wins 78% of listings. Manual processes can't compete with instant, intelligent voice responses.

The Solution Overview

This n8n workflow creates an AI voice agent that handles inbound calls using OpenAI's Realtime API for natural conversation, processes lead information through custom qualification logic, and syncs everything to your CRM automatically. The agent answers property questions by pulling data from your listings database, qualifies leads using your specific criteria, and books appointments directly into your calendar. It operates 24/7 with sub-second response times and natural conversation flow that prospects can't distinguish from human agents.

What You'll Build

Component Technology Purpose
Voice Interface OpenAI Realtime API Natural conversation with sub-second latency
Call Routing Twilio/Vonage Inbound call handling and phone number management
Lead Qualification n8n Function Nodes Custom business logic for lead scoring
Property Data Airtable/Google Sheets Real-time property information lookup
CRM Integration HubSpot/Zoho API Automatic lead creation and activity logging
Scheduling Calendly/Cal.com API Appointment booking with availability checking
Conversation Memory n8n Database Nodes Context retention across multiple calls
Analytics Dashboard Google Sheets Call metrics, conversion rates, and lead quality

Key capabilities:

  • Answers property-specific questions (price, bedrooms, location, availability)
  • Qualifies leads using budget, timeline, and motivation criteria
  • Schedules property showings based on agent availability
  • Handles objections and provides neighborhood information
  • Transfers to human agents for complex scenarios
  • Follows up with missed calls via SMS
  • Logs every conversation with transcripts in your CRM

Prerequisites

Before starting, ensure you have:

  • n8n instance (cloud or self-hosted)
  • OpenAI API account with Realtime API access ($0.06/minute)
  • Twilio account with phone number ($1/month + $0.0085/minute)
  • CRM account (HubSpot, Zoho, or FollowUpBoss) with API access
  • Property database (Airtable or Google Sheets)
  • Scheduling tool (Calendly or Cal.com) with API credentials
  • Basic JavaScript knowledge for Function nodes
  • Understanding of webhook concepts

Step 1: Configure Voice Call Infrastructure

Set up the phone system that routes inbound calls to your n8n workflow. This creates the entry point for all voice interactions.

Configure Twilio Phone Number

  1. Purchase a local phone number in your target market area
  2. Navigate to Phone Numbers → Active Numbers → Configure
  3. Set Voice & Fax webhook to your n8n webhook URL
  4. Enable call recording for quality assurance and training
  5. Set fallback URL to backup webhook endpoint

Node configuration:

{
  "webhook": {
    "httpMethod": "POST",
    "path": "real-estate-voice-agent",
    "responseMode": "responseNode",
    "authentication": "headerAuth"
  }
}

Why this works:
Twilio receives the inbound call and immediately sends call metadata (caller ID, timestamp, location) to your n8n webhook. The webhook triggers your workflow within 200ms, ensuring prospects don't hear dead air. Using POST method allows Twilio to send rich call data including caller location, which helps personalize the conversation.

Step 2: Initialize OpenAI Realtime Voice Session

Connect the call to OpenAI's Realtime API to enable natural voice conversation with minimal latency.

Set Up Realtime API Connection

  1. Add HTTP Request node configured for WebSocket connection
  2. Set endpoint to wss://api.openai.com/v1/realtime
  3. Add authentication header with your OpenAI API key
  4. Configure session parameters for voice model and instructions

Node configuration:

{
  "method": "POST",
  "url": "https://api.openai.com/v1/realtime/sessions",
  "authentication": "predefinedCredentialType",
  "nodeCredentialType": "openAiApi",
  "options": {
    "model": "gpt-4o-realtime-preview",
    "voice": "alloy",
    "instructions": "You are a professional real estate assistant. Qualify leads by asking about budget, timeline, and property preferences. Be friendly but efficient. Always offer to schedule a showing."
  }
}

Why this works:
The Realtime API maintains a persistent connection that processes voice in real-time rather than waiting for complete sentences. This creates natural conversation flow with interruptions and overlapping speech. The "alloy" voice provides professional, neutral tone suitable for real estate. Instructions prime the AI with your qualification criteria before the first word is spoken.

Variables to customize:

  • voice: Choose from alloy, echo, fable, onyx, nova, shimmer based on your brand
  • instructions: Add specific property details, pricing guidelines, and objection handling scripts
  • temperature: Set to 0.7 for consistent responses or 0.9 for more creative conversation

Step 3: Implement Lead Qualification Logic

Build the business rules that determine lead quality and routing priority.

Configure Qualification Function Node

  1. Add Function node after initial conversation capture
  2. Extract key qualification data from conversation transcript
  3. Score leads based on budget alignment, timeline urgency, and motivation
  4. Route high-priority leads to immediate agent notification

Node configuration:

// Extract qualification data from conversation
const transcript = $input.item.json.transcript;
const budget = extractBudget(transcript);
const timeline = extractTimeline(transcript);
const motivation = extractMotivation(transcript);

// Score lead (0-100)
let score = 0;

// Budget alignment (40 points)
if (budget >= 400000 && budget <= 600000) score += 40;
else if (budget >= 300000 && budget <= 700000) score += 25;
else score += 10;

// Timeline urgency (35 points)
if (timeline.includes('immediately') || timeline.includes('this week')) score += 35;
else if (timeline.includes('this month')) score += 25;
else if (timeline.includes('3 months')) score += 15;

// Motivation level (25 points)
if (motivation.includes('pre-approved') || motivation.includes('cash buyer')) score += 25;
else if (motivation.includes('looking seriously')) score += 15;

return {
  json: {
    leadScore: score,
    priority: score >= 70 ? 'hot' : score >= 50 ? 'warm' : 'cold',
    budget: budget,
    timeline: timeline,
    motivation: motivation,
    nextAction: score >= 70 ? 'immediate_callback' : 'schedule_showing'
  }
};

Why this approach:
Real estate conversion correlates directly with three factors: budget alignment (can they afford your properties?), timeline urgency (are they buying now?), and motivation level (are they serious?). This scoring system weights budget highest because misaligned budget wastes everyone's time. Timeline gets second priority because urgency predicts conversion. The 70/50 thresholds create clear action triggers: hot leads get immediate agent callbacks, warm leads get scheduled showings, cold leads enter nurture sequences.

Step 4: Integrate Property Database Lookup

Enable the AI agent to answer specific property questions by querying your listings database in real-time.

Configure Airtable Property Lookup

  1. Add Airtable node triggered when prospect asks about specific properties
  2. Query based on criteria mentioned in conversation (bedrooms, price range, location)
  3. Format property details for natural language response
  4. Cache frequently requested properties to reduce API calls

Node configuration:

{
  "operation": "list",
  "table": "Active Listings",
  "filterByFormula": "AND({Status}='Active', {Price}<={{budget}}, {Bedrooms}>={{minBedrooms}}, {Location}='{{preferredArea}}')",
  "sort": [{"field": "Price", "direction": "asc"}],
  "maxRecords": 5
}

Why this works:
The agent pulls live property data instead of relying on outdated training data. Filtering by budget and preferences ensures prospects only hear about properties they can afford and want. Sorting by price ascending shows the most accessible options first, increasing showing conversion. Limiting to 5 properties prevents overwhelming prospects with too many choices.

Step 5: Implement Appointment Scheduling

Connect to your scheduling system to book property showings automatically during the call.

Configure Calendly Integration

  1. Add HTTP Request node to check agent availability
  2. Present available time slots to prospect during conversation
  3. Create calendar event when prospect confirms time
  4. Send confirmation SMS with showing details

Node configuration:

{
  "method": "POST",
  "url": "https://api.calendly.com/scheduled_events",
  "headers": {
    "Authorization": "Bearer {{$credentials.calendlyApi.accessToken}}",
    "Content-Type": "application/json"
  },
  "body": {
    "event_type": "property-showing",
    "invitee_email": "{{$node.QualifyLead.json.email}}",
    "invitee_name": "{{$node.QualifyLead.json.name}}",
    "start_time": "{{$node.SelectTimeSlot.json.selectedTime}}",
    "location": "{{$node.PropertyLookup.json.address}}",
    "questions_and_answers": [
      {"question": "Property of interest", "answer": "{{$node.PropertyLookup.json.propertyId}}"},
      {"question": "Lead score", "answer": "{{$node.QualifyLead.json.leadScore}}"}
    ]
  }
}

Why this approach:
Booking appointments during the initial call increases showing attendance by 45% compared to follow-up scheduling. Passing lead score and property details to the calendar event gives agents context before the showing. The confirmation SMS reduces no-shows from 30% to 12%.

Step 6: Sync Lead Data to CRM

Push all conversation data, lead scores, and scheduled appointments to your CRM for agent follow-up.

Configure HubSpot Contact Creation

  1. Add HubSpot node after lead qualification
  2. Create or update contact with conversation transcript
  3. Log call activity with duration and outcome
  4. Assign to appropriate agent based on territory or lead score

Node configuration:

{
  "operation": "upsert",
  "email": "{{$node.ExtractContactInfo.json.email}}",
  "properties": {
    "firstname": "{{$node.ExtractContactInfo.json.firstName}}",
    "lastname": "{{$node.ExtractContactInfo.json.lastName}}",
    "phone": "{{$node.Webhook.json.From}}",
    "lead_score": "{{$node.QualifyLead.json.leadScore}}",
    "lead_source": "AI Voice Agent",
    "budget": "{{$node.QualifyLead.json.budget}}",
    "timeline": "{{$node.QualifyLead.json.timeline}}",
    "property_interests": "{{$node.PropertyLookup.json.propertyIds}}",
    "last_call_transcript": "{{$node.OpenAI.json.transcript}}",
    "next_action": "{{$node.QualifyLead.json.nextAction}}"
  }
}

Workflow Architecture Overview

This workflow consists of 18 nodes organized into 5 main sections:

  1. Call handling (Nodes 1-3): Webhook receives Twilio call, initializes OpenAI Realtime session, establishes voice connection
  2. Conversation processing (Nodes 4-8): Captures transcript, extracts contact info, identifies intent, routes to appropriate handler
  3. Lead qualification (Nodes 9-11): Scores lead based on budget/timeline/motivation, determines priority level, triggers appropriate follow-up
  4. Property lookup (Nodes 12-14): Queries Airtable for matching properties, formats details for voice response, caches results
  5. CRM sync & scheduling (Nodes 15-18): Creates/updates HubSpot contact, books Calendly appointment, sends confirmation SMS, logs activity

Execution flow:

  • Trigger: Inbound call to Twilio number
  • Average run time: 45-180 seconds (depends on conversation length)
  • Key dependencies: OpenAI API, Twilio, Airtable, HubSpot, Calendly

Critical nodes:

  • OpenAI Realtime API: Handles natural voice conversation with context retention
  • Function (Lead Qualification): Processes transcript to extract and score qualification data
  • Airtable Query: Retrieves property details based on prospect preferences
  • HubSpot Upsert: Syncs all lead data to CRM for agent follow-up

The complete n8n workflow JSON template is available at the bottom of this article.

Key Configuration Details

OpenAI Realtime API Settings

Required fields:

  • API Key: Your OpenAI API key with Realtime API access
  • Model: gpt-4o-realtime-preview (only model supporting voice)
  • Voice: alloy (professional, neutral tone)
  • Instructions: Your custom agent personality and qualification script

Common issues:

  • Using wrong model → Results in "model not found" errors. Always use gpt-4o-realtime-preview
  • Insufficient API credits → Calls fail mid-conversation. Monitor usage at $0.06/minute
  • Missing instructions → Agent lacks context and asks irrelevant questions

Twilio Configuration

Required fields:

  • Account SID: Found in Twilio console dashboard
  • Auth Token: Used for webhook authentication
  • Phone Number: Must be voice-enabled with webhook configured
  • Webhook URL: Your n8n webhook endpoint with HTTPS

Why this approach:
Twilio provides enterprise-grade call reliability with 99.95% uptime. The webhook architecture allows n8n to process calls without maintaining persistent connections. Using POST webhooks enables rich metadata transfer including caller location, which helps personalize greetings ("I see you're calling from Austin...").

Variables to customize:

  • qualificationThresholds: Adjust 70/50 scores based on your lead volume and agent capacity
  • propertyMatchCriteria: Modify Airtable filters to match your inventory structure
  • agentAssignmentRules: Change territory or round-robin logic for lead distribution

Testing & Validation

Test each component:

  1. Voice quality test: Call your Twilio number and verify audio clarity, response latency under 1 second, natural conversation flow
  2. Qualification accuracy: Run 10 test calls with different scenarios (high budget/urgent, low budget/browsing, etc.) and verify scoring
  3. Property lookup: Ask about specific properties and confirm correct details are retrieved from Airtable
  4. CRM sync: Check HubSpot after each test call to verify contact creation, transcript logging, and lead scoring
  5. Appointment booking: Schedule test showings and confirm calendar events appear in Calendly with correct details

Common issues:

  • Choppy audio → Increase n8n instance resources or use dedicated voice server
  • Incorrect lead scores → Review Function node logic and adjust thresholds
  • Missing CRM data → Check HubSpot API permissions and field mappings
  • Failed appointments → Verify Calendly event type settings and availability rules

Production Deployment Checklist

Area Requirement Why It Matters
Error Handling Retry logic with exponential backoff on API failures Prevents lost leads when CRM or scheduling APIs timeout
Monitoring Webhook health checks every 2 minutes Detect Twilio connection failures within 2 minutes vs discovering when leads complain
Call Recording Enable Twilio call recording with 90-day retention Required for quality assurance, training, and compliance in most states
Fallback Routing Human agent transfer trigger on AI confusion Prevents frustrating loops when AI can't understand accent or complex question
Rate Limiting Max 50 concurrent calls per n8n instance Prevents OpenAI API rate limit errors during high call volume
Data Backup Daily export of conversation transcripts to S3 Protects against data loss and enables conversation analysis
Cost Monitoring Alert when daily OpenAI spend exceeds $50 Prevents surprise bills from runaway API usage

Real-World Use Cases

Use Case 1: High-Volume Buyer Lead Qualification

  • Industry: Residential real estate brokerage
  • Scale: 200-300 inbound calls per week
  • Modifications needed: Add Spanish language support using OpenAI's multilingual capabilities, integrate with MLS for broader property search, implement SMS follow-up for missed calls

Use Case 2: Luxury Property Concierge

  • Industry: Luxury real estate ($1M+ properties)
  • Scale: 50-75 high-value inquiries per week
  • Modifications needed: Increase qualification thresholds (budget minimum $800K), add private showing coordination, integrate with DocuSign for NDA handling before property details

Use Case 3: Commercial Real Estate Tenant Screening

  • Industry: Commercial property management
  • Scale: 100-150 tenant inquiries per month
  • Modifications needed: Replace budget questions with business type and square footage needs, add credit check integration, schedule property tours instead of showings

Use Case 4: Property Management Maintenance Requests

  • Industry: Residential property management
  • Scale: 500+ maintenance calls per month
  • Modifications needed: Replace lead qualification with issue categorization (urgent/routine), integrate with maintenance ticket system, schedule vendor appointments instead of showings

Customizing This Workflow

Alternative Integrations

Instead of HubSpot:

  • Zoho CRM: Best for smaller teams - requires changing API endpoints in nodes 15-16
  • FollowUpBoss: Better for real estate teams - swap HubSpot node for HTTP Request with FollowUpBoss API
  • Salesforce: Use when enterprise features needed - add Salesforce node and map custom fields

Instead of Calendly:

  • Cal.com: Open-source alternative - change API endpoint and authentication method
  • Google Calendar: Direct booking - requires OAuth setup and availability logic in Function node
  • Acuity Scheduling: Better customization - swap Calendly node for Acuity API calls

Workflow Extensions

Add automated follow-up sequences:

  • Add Schedule node to trigger 24 hours after call
  • Connect to SendGrid for email follow-up
  • Send property updates matching prospect criteria
  • Nodes needed: +4 (Schedule, SendGrid, Airtable Query, Function)

Scale to handle multiple agents:

  • Replace single Calendly account with agent-specific calendars
  • Add round-robin or territory-based assignment logic
  • Implement agent performance tracking
  • Performance improvement: Distribute 300 leads across 10 agents automatically

Add conversation analytics:

Add This To Get This Complexity
Sentiment analysis Track prospect enthusiasm and objections Medium (3 nodes)
Keyword extraction Identify common questions and pain points Easy (2 nodes)
Conversion tracking Measure showing-to-offer rates by lead source Medium (5 nodes)
Agent coaching reports Weekly performance summaries with call highlights Hard (8 nodes)

Implement multi-language support:

  • Add language detection in initial conversation
  • Route to language-specific OpenAI instructions
  • Translate property details dynamically
  • Complexity: Medium (6 additional nodes)

Get Started Today

Ready to automate your real estate lead handling?

  1. Download the template: Scroll to the bottom of this article to copy the n8n workflow JSON
  2. Import to n8n: Go to Workflows → Import from URL or File, paste the JSON
  3. Configure your services: Add API credentials for OpenAI, Twilio, HubSpot, Airtable, and Calendly
  4. Customize qualification logic: Edit the Function node to match your budget ranges and lead criteria
  5. Test with sample calls: Call your Twilio number and verify each component works before going live
  6. Deploy to production: Activate the workflow and update your business phone number to route to Twilio

Need help customizing this workflow for your specific real estate business? Schedule an intro call with Atherial.

Complete N8N Workflow Template

Copy the JSON below and import it into your N8N instance via Workflows → Import from File

{
  "name": "AI Voice Agent Lead Handler",
  "nodes": [
    {
      "id": "webhook-trigger",
      "name": "Lead Inquiry Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        50,
        100
      ],
      "parameters": {
        "path": "real-estate/voice-lead",
        "httpMethod": "POST",
        "responseData": "firstEntryJson",
        "responseMode": "onReceived"
      },
      "typeVersion": 2
    },
    {
      "id": "set-variables",
      "name": "Extract Lead Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        250,
        100
      ],
      "parameters": {
        "mode": "fromList",
        "fromListUI": {
          "values": [
            {
              "name": "callerName",
              "value": "{{ $json.caller_name }}"
            },
            {
              "name": "callerPhone",
              "value": "{{ $json.caller_phone }}"
            },
            {
              "name": "callerEmail",
              "value": "{{ $json.caller_email }}"
            },
            {
              "name": "propertyBudget",
              "value": "{{ $json.property_budget }}"
            },
            {
              "name": "propertyLocation",
              "value": "{{ $json.property_location }}"
            },
            {
              "name": "inquiryText",
              "value": "{{ $json.inquiry_text }}"
            },
            {
              "name": "callTranscript",
              "value": "{{ $json.call_transcript }}"
            }
          ]
        }
      },
      "typeVersion": 3
    },
    {
      "id": "ai-lead-qualifier",
      "name": "AI Lead Qualification",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        450,
        100
      ],
      "parameters": {
        "model": "gpt-4",
        "messages": {
          "messageValues": [
            {
              "content": "You are a professional real estate lead qualification specialist. Analyze the following lead inquiry and provide a structured assessment:\n\nCaller Name: {{ $vars.callerName }}\nPhone: {{ $vars.callerPhone }}\nEmail: {{ $vars.callerEmail }}\nBudget: {{ $vars.propertyBudget }}\nLocation Interest: {{ $vars.propertyLocation }}\nInquiry: {{ $vars.inquiryText }}\nCall Transcript: {{ $vars.callTranscript }}\n\nProvide your response in JSON format with these fields:\n- leadQuality (HIGH, MEDIUM, LOW)\n- qualificationScore (0-100)\n- propertyType (inferred from inquiry)\n- timeline (immediate, 1-3 months, 3-6 months, flexible)\n- buyerMotivation (investor, first-time buyer, upgrade, downsizing, relocating)\n- recommendedFollowUp (email, phone call, property preview)\n- notes (brief summary for the agent)"
            }
          ]
        },
        "temperature": 0.3
      },
      "typeVersion": 1
    },
    {
      "id": "parse-ai-response",
      "name": "Parse AI Response",
      "type": "n8n-nodes-base.code",
      "position": [
        650,
        100
      ],
      "parameters": {
        "value": "={{ JSON.parse($json.text) }}",
        "dataType": "json"
      },
      "typeVersion": 2
    },
    {
      "id": "check-lead-quality",
      "name": "Check Lead Quality",
      "type": "n8n-nodes-base.if",
      "position": [
        850,
        100
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.leadQuality }}",
              "value2": "HIGH",
              "operation": "equals"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "hubspot-upsert-contact",
      "name": "Create/Update HubSpot Contact",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        1050,
        50
      ],
      "parameters": {
        "email": "={{ $vars.callerEmail }}",
        "resource": "contact",
        "operation": "upsert",
        "additionalFields": {
          "properties": [
            {
              "key": "firstname",
              "value": "={{ $vars.callerName }}"
            },
            {
              "key": "phone",
              "value": "={{ $vars.callerPhone }}"
            },
            {
              "key": "property_interest",
              "value": "={{ $json.propertyType }}"
            },
            {
              "key": "budget",
              "value": "={{ $vars.propertyBudget }}"
            },
            {
              "key": "location_preference",
              "value": "={{ $vars.propertyLocation }}"
            },
            {
              "key": "buyer_motivation",
              "value": "={{ $json.buyerMotivation }}"
            },
            {
              "key": "timeline",
              "value": "={{ $json.timeline }}"
            },
            {
              "key": "lead_score",
              "value": "={{ $json.qualificationScore }}"
            },
            {
              "key": "lead_status",
              "value": "{{ $json.leadQuality }}"
            },
            {
              "key": "source",
              "value": "Voice Agent"
            }
          ]
        }
      },
      "credentials": {
        "hubspotApi": {
          "id": "hubspot_cred_id",
          "name": "HubSpot API"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "hubspot-log-engagement",
      "name": "Log Call Engagement in HubSpot",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        1050,
        150
      ],
      "parameters": {
        "body": {
          "metadata": {
            "body": "AI Voice Agent Lead Qualification Call - {{ $json.leadQuality }} Priority",
            "status": "COMPLETED",
            "duration": 0,
            "toNumber": "+1234567890",
            "direction": "INBOUND",
            "externalId": "voice-agent-call",
            "fromNumber": "={{ $vars.callerPhone }}"
          },
          "engagement": {
            "type": "CALL",
            "timestamp": "={{ Date.now() }}"
          }
        },
        "resource": "engagement",
        "contactId": "={{ $json.id }}",
        "operation": "create",
        "engagementType": "CALL"
      },
      "credentials": {
        "hubspotApi": {
          "id": "hubspot_cred_id",
          "name": "HubSpot API"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "check-calendar-availability",
      "name": "Check Calendar Availability",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        1250,
        50
      ],
      "parameters": {
        "timeMax": "={{ $now.plus(7, 'days') }}",
        "timeMin": "={{ $now }}",
        "calendar": "={{ $response.calendar_id }}",
        "resource": "event",
        "operation": "find"
      },
      "credentials": {
        "googleCalendarOAuth2": {
          "id": "google_calendar_cred_id",
          "name": "Google Calendar"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "schedule-appointment",
      "name": "Schedule Appointment",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        1250,
        150
      ],
      "parameters": {
        "end": "={{ $now.plus(2, 'days').set({hour: 11, minute: 0}) }}",
        "start": "={{ $now.plus(2, 'days').set({hour: 10, minute: 0}) }}",
        "summary": "{{ $vars.callerName }} - Property Preview: {{ $json.propertyType }}",
        "calendar": "={{ $response.calendar_id }}",
        "resource": "event",
        "attendees": {
          "email": "={{ $vars.callerEmail }}"
        },
        "operation": "create",
        "description": "Lead Qualification Score: {{ $json.qualificationScore }}/100\nMotivation: {{ $json.buyerMotivation }}\nTimeline: {{ $json.timeline }}\nNotes: {{ $json.notes }}"
      },
      "credentials": {
        "googleCalendarOAuth2": {
          "id": "google_calendar_cred_id",
          "name": "Google Calendar"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "generate-voice-response",
      "name": "Generate Voice Response",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1450,
        50
      ],
      "parameters": {
        "url": "https://api.elevenlabs.io/v1/text-to-speech/{{ $env.ELEVENLABS_VOICE_ID }}",
        "body": {
          "text": "Thank you for your inquiry. I've reviewed your information and identified you as a {{ $json.leadQuality }} priority lead. An appointment has been scheduled for {{ $json.nextAvailableTime }}. You should receive a confirmation email shortly. Looking forward to helping you find your perfect property!",
          "model_id": "eleven_monolingual_v1",
          "voice_settings": {
            "stability": 0.5,
            "similarity_boost": 0.75
          }
        },
        "method": "POST",
        "sendBody": true,
        "contentType": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "bearerToken"
      },
      "typeVersion": 4
    },
    {
      "id": "openai-tts-response",
      "name": "OpenAI Text-to-Speech",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1450,
        120
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/audio/speech",
        "body": {
          "input": "Thank you for your inquiry. I have qualified you as a {{ $json.leadQuality }} priority lead. A property specialist will contact you within 24 hours to schedule a viewing.",
          "model": "tts-1",
          "speed": 1,
          "voice": "alloy"
        },
        "method": "POST",
        "sendBody": true,
        "contentType": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "bearerToken"
      },
      "typeVersion": 4
    },
    {
      "id": "send-confirmation-email",
      "name": "Send Confirmation Email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1450,
        200
      ],
      "parameters": {
        "html": "<h2>Your Real Estate Inquiry Summary</h2><p>Hello {{ $vars.callerName }},</p><p>Thank you for reaching out! Our AI assistant has analyzed your inquiry:</p><ul><li><strong>Lead Priority:</strong> {{ $json.leadQuality }}</li><li><strong>Qualification Score:</strong> {{ $json.qualificationScore }}/100</li><li><strong>Property Interest:</strong> {{ $json.propertyType }}</li><li><strong>Timeline:</strong> {{ $json.timeline }}</li></ul><p><strong>Notes:</strong> {{ $json.notes }}</p><p>A specialist will contact you within 24 hours.</p>",
        "text": "Hello {{ $vars.callerName }},\n\nThank you for reaching out! Our AI assistant has reviewed your inquiry and identified the following:\n\n✓ Lead Priority: {{ $json.leadQuality }}\n✓ Qualification Score: {{ $json.qualificationScore }}/100\n✓ Property Type: {{ $json.propertyType }}\n✓ Timeline: {{ $json.timeline }}\n✓ Recommended Follow-up: {{ $json.recommendedFollowUp }}\n\nDetails:\n{{ $json.notes }}\n\nNext Steps:\nA specialist from our team will contact you at {{ $vars.callerPhone }} within 24 hours to discuss properties that match your criteria and schedule a viewing.\n\nBest regards,\nReal Estate AI Assistant\nContact: support@realestate-ai.com",
        "subject": "Your Real Estate Inquiry - Next Steps",
        "toEmail": "={{ $vars.callerEmail }}",
        "fromEmail": "noreply@realestate-ai.com"
      },
      "typeVersion": 1
    },
    {
      "id": "notify-sales-team",
      "name": "Notify Sales Team",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1450,
        280
      ],
      "parameters": {
        "html": "<h3>New Lead Assigned</h3><p><strong>Name:</strong> {{ $vars.callerName }}</p><p><strong>Phone:</strong> {{ $vars.callerPhone }}</p><p><strong>Email:</strong> {{ $vars.callerEmail }}</p><p><strong>Priority:</strong> {{ $json.leadQuality }}</p><p><strong>Score:</strong> {{ $json.qualificationScore }}/100</p><p><strong>Property Type:</strong> {{ $json.propertyType }}</p><p><strong>Budget:</strong> {{ $vars.propertyBudget }}</p><p><strong>Location:</strong> {{ $vars.propertyLocation }}</p><p><strong>Timeline:</strong> {{ $json.timeline }}</p><p><strong>Motivation:</strong> {{ $json.buyerMotivation }}</p><p><strong>Assessment:</strong> {{ $json.notes }}</p><p><strong>Appointment Scheduled:</strong> {{ $json.nextAvailableTime }}</p><p>View in HubSpot: <a href='https://app.hubspotusercontent.com/contacts/{{ $json.id }}'>Click here</a></p>",
        "subject": "New {{ $json.leadQuality }} Priority Lead - {{ $vars.callerName }}",
        "toEmail": "sales-team@realestate.com",
        "fromEmail": "admin@realestate-ai.com"
      },
      "typeVersion": 1
    },
    {
      "id": "send-low-priority-followup",
      "name": "Send Low Priority Follow-up",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1050,
        300
      ],
      "parameters": {
        "text": "Hello {{ $vars.callerName }},\n\nThank you for contacting us. Your inquiry has been received and we're reviewing your information.\n\nWe'll reach out to you shortly at {{ $vars.callerPhone }} to discuss properties that match your needs.\n\nBest regards,\nReal Estate Team",
        "subject": "Thank You - We'll Follow Up Soon",
        "toEmail": "={{ $vars.callerEmail }}",
        "fromEmail": "noreply@realestate-ai.com"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Parse AI Response": {
      "main": [
        [
          {
            "node": "Check Lead Quality",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Lead Quality": {
      "main": [
        [
          {
            "node": "Create/Update HubSpot Contact",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Low Priority Follow-up",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lead Inquiry Webhook": {
      "main": [
        [
          {
            "node": "Extract Lead Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Appointment": {
      "main": [
        [
          {
            "node": "Generate Voice Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Lead Qualification": {
      "main": [
        [
          {
            "node": "Parse AI Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Text-to-Speech": {
      "main": [
        [
          {
            "node": "Send Confirmation Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Lead Variables": {
      "main": [
        [
          {
            "node": "AI Lead Qualification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Voice Response": {
      "main": [
        [
          {
            "node": "OpenAI Text-to-Speech",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Confirmation Email": {
      "main": [
        [
          {
            "node": "Notify Sales Team",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Calendar Availability": {
      "main": [
        [
          {
            "node": "Schedule Appointment",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create/Update HubSpot Contact": {
      "main": [
        [
          {
            "node": "Log Call Engagement in HubSpot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Call Engagement in HubSpot": {
      "main": [
        [
          {
            "node": "Check Calendar Availability",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}