# Real estate agent (API) (/docs/examples/real-estate)

> Build a voice agent that handles property inquiries, schedules viewings, and manages client interactions via the API.







<img alt="Real estate agent overview" src="__img0" />

Build an inbound real estate voice agent end to end with the
OmniDimension Python SDK. The agent presents property listings, matches
client requirements, schedules viewings, and tracks call analytics.

<Steps>
  <Step>
    ### Get your API key [#get-your-api-key]

    Get an API key from the OmniDimension dashboard, in the API section.

        <img alt="API key" src="__img1" />
  </Step>

  <Step>
    ### Create the real estate assistant [#create-the-real-estate-assistant]

    Start by creating your voice agent with real estate-specific
    configuration.

    ```python
    from omnidimension import Client

    client = Client("your_api_key_here")

    real_estate_agent = client.agent.create(
        name="Sarah - Premier Properties Assistant",
        welcome_message="Hello! This is Sarah from Premier Properties. I'm here to help you find your dream home or assist with any property inquiries. How can I help you today?",
        context_breakdown=[
            {
                "title": "Available Properties",
                "body": """RESIDENTIAL PROPERTIES:
    - 3BR Luxury Condo: $450,000 | 2,200 sq ft | Downtown
    - 4BR Family Home: $650,000 | 3,500 sq ft | Suburbs
    - 2BR Starter Home: $325,000 | 1,800 sq ft | City Center

    RENTAL PROPERTIES:
    - 2BR Apartment: $2,200/month | 1,200 sq ft | Downtown
    - 3BR Townhouse: $3,500/month | 2,000 sq ft | Suburbs
    - 1BR Studio: $1,500/month | 800 sq ft | City Center

    COMMERCIAL PROPERTIES:
    - Office Space: $25/sq ft | 5,000 sq ft | Business District
    - Retail Space: $30/sq ft | 3,000 sq ft | Shopping Center
    - Warehouse: $15/sq ft | 10,000 sq ft | Industrial Zone"""
            },
            {
                "title": "Inquiry Process",
                "body": "1. Greet client professionally 2. Understand property requirements 3. Match with available listings 4. Schedule viewings if interested 5. Collect contact information 6. Provide market information"
            },
            {
                "title": "Service Areas",
                "body": "We serve the entire metropolitan area including Downtown, Suburbs, and surrounding neighborhoods. Our agents specialize in residential, commercial, and rental properties."
            }
        ],
        call_type="Incoming",
        voice={
            "provider": "eleven_labs",
            "voice_id": "EXAVITQu4vr4xnSDxMaL"
        },
        model={
            "provider": "anthropic",
            "model": "gpt-4o-mini",
            "temperature": 0.6
        }
    )

    agent_id = real_estate_agent["json"]["id"]
    print(f"Real estate agent created with ID: {agent_id}")
    ```

    **Key components:**

    * `welcome_message`: professional greeting establishing expertise
    * Property listings: comprehensive inventory with prices and details
    * Inquiry process: step-by-step workflow for handling inquiries
    * Service areas: geographic coverage information
    * Voice configuration: professional, trustworthy voice
  </Step>

  <Step>
    ### Upload property documentation [#upload-property-documentation]

    Enhance your agent's knowledge by uploading property brochures.

    ```python
    import base64

    def upload_property_documentation(agent_id, brochure_path):
        """Upload property brochure to knowledge base and attach to agent"""

        # Read and encode the PDF file
        with open(brochure_path, "rb") as file:
            file_data = base64.b64encode(file.read()).decode('utf-8')

        # Upload to knowledge base
        kb_response = client.knowledge_base.create(file_data, "Property_Brochure.pdf")
        file_id = kb_response["json"]["file"]["id"]

        # Attach to agent
        attach_response = client.knowledge_base.attach([file_id], agent_id)

        print(f"Property documentation uploaded successfully. File ID: {file_id}")
        return file_id

    # Upload your property brochure
    brochure_file_id = upload_property_documentation(agent_id, "property_brochure.pdf")
    ```
  </Step>

  <Step>
    ### Handle incoming client calls [#handle-incoming-client-calls]

    Your agent is now ready to handle incoming calls. When clients call your
    office number, the agent will:

    * Greet clients with the welcome message
    * Understand requirements (property type, budget, location)
    * Present matching properties based on client preferences
    * Schedule viewings for interested properties
    * Collect contact information for follow-up
    * Provide market information and next steps
  </Step>

  <Step>
    ### Monitor performance and analytics [#monitor-performance-and-analytics]

    Track your real estate agent's performance.

    ```python
    def get_real_estate_analytics(agent_id, days=7):
        """Get comprehensive analytics for real estate agent"""

        # Get recent call logs
        call_logs = client.call.get_call_logs(agent_id=agent_id, page_size=100)
        calls_data = call_logs.get('data', [])

        # Calculate metrics
        total_calls = len(calls_data)
        successful_calls = sum(1 for call in calls_data if call.get('status') == 'completed')
        average_duration = sum(call.get('duration', 0) for call in calls_data) / total_calls if total_calls > 0 else 0

        # Generate report
        analytics_report = {
            "period_days": days,
            "total_calls": total_calls,
            "successful_calls": successful_calls,
            "completion_rate": f"{(successful_calls/total_calls*100):.1f}%" if total_calls > 0 else "0%",
            "average_call_duration": f"{average_duration:.1f} seconds",
            "recent_calls": calls_data[:5]  # Last 5 calls
        }

        return analytics_report

    # Get weekly performance report
    weekly_report = get_real_estate_analytics(agent_id, days=7)

    print("Real Estate Agent Performance Report")
    print(f"Total Calls: {weekly_report['total_calls']}")
    print(f"Successful Calls: {weekly_report['successful_calls']}")
    print(f"Completion Rate: {weekly_report['completion_rate']}")
    print(f"Average Call Duration: {weekly_report['average_call_duration']}")
    ```
  </Step>

  <Step>
    ### Update agent configuration [#update-agent-configuration]

    Modify your agent settings as needed.

    ```python
    def update_agent_details(agent_id, **kwargs):
        """Update agent configuration"""
        response = client.agent.update(agent_id, **kwargs)
        print(f"Agent updated successfully")
        return response

    # Update welcome message for weekend hours
    update_agent_details(
        agent_id,
        welcome_message="Good morning! Welcome to Premier Properties. Our weekend open houses are ready! How can I help you find your dream home?"
    )

    # Switch back to incoming calls
    update_agent_details(
        agent_id,
        call_type="Incoming"
    )
    ```
  </Step>

  <Step>
    ### Complete setup [#complete-setup]

    Here's the complete setup for a production-ready real estate agent.

    ```python
    from omnidimension import Client
    import base64

    class RealEstateVoiceAgent:
        def __init__(self, api_key):
            self.client = Client(api_key)
            self.agent_id = None

        def setup_complete_real_estate_agent(self):
            """Set up a complete real estate voice agent with all features"""

            # Create the main agent
            agent = self.client.agent.create(
                name="Premier Properties - Voice Assistant",
                welcome_message="Hello! This is Sarah from Premier Properties. I'm here to help you find your dream home or assist with any property inquiries. How can I help you today?",
                context_breakdown=[
                    {
                        "title": "Complete Property Listings",
                        "body": """
                        RESIDENTIAL PROPERTIES:
                        - 3BR Luxury Condo: $450,000 | 2,200 sq ft | Downtown | Amenities: Pool, Gym, Doorman
                        - 4BR Family Home: $650,000 | 3,500 sq ft | Suburbs | Features: Large Yard, 2-Car Garage
                        - 2BR Starter Home: $325,000 | 1,800 sq ft | City Center | Features: Renovated Kitchen, Hardwood Floors
                        - 5BR Executive Home: $850,000 | 4,200 sq ft | Gated Community | Features: Home Office, Pool

                        RENTAL PROPERTIES:
                        - 2BR Apartment: $2,200/month | 1,200 sq ft | Downtown | Utilities Included
                        - 3BR Townhouse: $3,500/month | 2,000 sq ft | Suburbs | Pet-Friendly
                        - 1BR Studio: $1,500/month | 800 sq ft | City Center | Furnished Option Available
                        - 4BR House: $4,000/month | 2,800 sq ft | Suburbs | 12-month Lease

                        COMMERCIAL PROPERTIES:
                        - Office Space: $25/sq ft | 5,000 sq ft | Business District | Class A Building
                        - Retail Space: $30/sq ft | 3,000 sq ft | Shopping Center | High Foot Traffic
                        - Warehouse: $15/sq ft | 10,000 sq ft | Industrial Zone | Loading Docks
                        - Restaurant Space: $35/sq ft | 2,500 sq ft | Downtown | Former Restaurant
                        """
                    },
                    {
                        "title": "Client Service Guidelines",
                        "body": "Always be professional and helpful. Listen carefully to client requirements. Suggest properties that match their needs. Offer virtual tours when possible. Follow up within 24 hours of initial inquiry."
                    },
                    {
                        "title": "Operational Details",
                        "body": "Office hours: 9 AM - 7 PM weekdays, 10 AM - 5 PM weekends. Service areas: Downtown, Suburbs, and surrounding neighborhoods. Specialties: Residential, Commercial, and Rental properties. Viewing appointments: 1-hour slots."
                    }
                ],
                call_type="Incoming",
                voice={
                    "provider": "eleven_labs",
                    "voice_id": "EXAVITQu4vr4xnSDxMaL"
                },
                model={
                    "provider": "anthropic",
                    "model": "gpt-4o-mini",
                    "temperature": 0.6
                }
            )

            self.agent_id = agent["json"]["id"]
            print(f"Real estate agent created: {self.agent_id}")

            return self.agent_id

        def get_performance_summary(self):
            """Get a quick performance summary"""
            if not self.agent_id:
                return "No agent configured"

            calls = self.client.call.get_call_logs(agent_id=self.agent_id, page_size=50)
            total_calls = len(calls.get('data', []))

            return {
                "agent_id": self.agent_id,
                "total_calls_handled": total_calls,
                "status": "Active and ready for inquiries!"
            }

        def upload_property_brochure(self, brochure_path):
            """Upload property brochure to knowledge base"""
            if not self.agent_id:
                print("Please create agent first")
                return None

            with open(brochure_path, "rb") as file:
                file_data = base64.b64encode(file.read()).decode('utf-8')

            kb_response = self.client.knowledge_base.create(file_data, "Property_Brochure.pdf")
            file_id = kb_response["json"]["file"]["id"]

            self.client.knowledge_base.attach([file_id], self.agent_id)
            print(f"Property brochure uploaded: {file_id}")
            return file_id

    # Initialize and deploy real estate agent
    real_estate = RealEstateVoiceAgent("your_api_key_here")
    agent_id = real_estate.setup_complete_real_estate_agent()

    # Upload brochure if you have a PDF
    # real_estate.upload_property_brochure("property_brochure.pdf")

    print("\nYour real estate voice agent is now live!")
    print(f"Agent ID: {agent_id}")
    ```
  </Step>
</Steps>

## Key features [#key-features]

### Property management [#property-management]

* Complete property listings with prices and details
* Property matching through natural conversation
* Viewing scheduling and coordination
* Property information and market updates

### Call handling [#call-handling]

* Incoming client calls for property inquiries
* Natural conversation flow
* Professional real estate service experience
* Efficient lead qualification

### Analytics and monitoring [#analytics-and-monitoring]

* Call volume tracking
* Call completion rates
* Average call duration
* Detailed call logs and history

### Knowledge base [#knowledge-base]

* Upload property brochures for enhanced knowledge
* Attach multiple documents to your agent
* Comprehensive property and market information
* Easy knowledge management

### Agent management [#agent-management]

* Update agent configuration anytime
* Modify welcome messages and context
* Real-time agent performance monitoring
* Easy property listing updates
