Systems Library / Industry Applications / How to Automate Real Estate Social Media Posting
Industry Applications real estate

How to Automate Real Estate Social Media Posting

Post new listings and market updates to social media automatically.

Jay Banlasan

Jay Banlasan

The AI Systems Guy

Automating real estate social media posting for listings keeps your feed active without the daily grind of creating posts. I built this for agents who know they should post regularly but never find the time. New listings automatically generate social posts, market updates publish weekly, and the agent just reviews and approves.

What You Need Before Starting

Step 1: Generate Social Media Captions

import anthropic
from dotenv import load_dotenv
load_dotenv()

def generate_social_caption(listing, platform="instagram"):
    client = anthropic.Anthropic()
    
    platform_rules = {
        "instagram": "Under 150 words. Use 5-8 relevant hashtags at the end. Conversational. No ALL CAPS.",
        "facebook": "Under 100 words. No hashtags. Include a question to drive comments. Friendly tone.",
        "linkedin": "Professional tone. Under 100 words. Focus on investment value or market insight."
    }
    
    response = client.messages.create(
        model="claude-sonnet-4-20250514",
        max_tokens=512,
        system=f"You are a real estate agent writing social media posts. {platform_rules.get(platform, platform_rules['instagram'])}",
        messages=[{
            "role": "user",
            "content": f"""Write a {platform} post for this listing:
Address: {listing['address']}
Price: {listing['price']}
Beds/Baths: {listing['bedrooms']}bd/{listing['bathrooms']}ba
Sqft: {listing['sqft']}
Features: {', '.join(listing.get('features', []))}
Neighborhood: {listing.get('neighborhood', '')}"""
        }]
    )
    
    return response.content[0].text

Step 2: Generate Market Update Posts

def generate_market_update(market_data, platform="instagram"):
    client = anthropic.Anthropic()
    
    response = client.messages.create(
        model="claude-sonnet-4-20250514",
        max_tokens=512,
        system=f"You are a real estate agent sharing weekly market insights on {platform}. Data-backed, not hype. Under 120 words.",
        messages=[{
            "role": "user",
            "content": f"""Write a market update post with this data:
Area: {market_data['area']}
Avg price this month: ${market_data['avg_price']:,}
Price change from last month: {market_data['price_change']}%
Days on market avg: {market_data['avg_dom']}
Active listings: {market_data['active_count']}
Sold this month: {market_data['sold_count']}"""
        }]
    )
    
    return response.content[0].text

Step 3: Build the Content Calendar

import sqlite3
from datetime import datetime, timedelta

def init_social_db(db_path="social_posts.db"):
    conn = sqlite3.connect(db_path)
    conn.execute("""
        CREATE TABLE IF NOT EXISTS scheduled_posts (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            platform TEXT,
            post_type TEXT,
            caption TEXT,
            image_path TEXT,
            scheduled_for TEXT,
            status TEXT DEFAULT 'draft',
            published_at TEXT,
            listing_id TEXT
        )
    """)
    conn.commit()
    conn.close()

def schedule_listing_posts(listing, photo_path, db_path="social_posts.db"):
    conn = sqlite3.connect(db_path)
    platforms = ["instagram", "facebook"]
    
    for i, platform in enumerate(platforms):
        caption = generate_social_caption(listing, platform)
        schedule_time = (datetime.utcnow() + timedelta(hours=i * 2)).isoformat()
        
        conn.execute("""
            INSERT INTO scheduled_posts (platform, post_type, caption, image_path, scheduled_for, listing_id)
            VALUES (?,?,?,?,?,?)
        """, (platform, "new_listing", caption, photo_path, schedule_time, listing.get("mls_id", "")))
    
    conn.commit()
    conn.close()

Step 4: Publish Posts via API

import requests

def publish_to_facebook(caption, image_path, page_token, page_id):
    with open(image_path, "rb") as img:
        response = requests.post(
            f"https://graph.facebook.com/v19.0/{page_id}/photos",
            data={"message": caption, "access_token": page_token},
            files={"source": img}
        )
    return response.json()

def process_scheduled_posts(db_path="social_posts.db"):
    conn = sqlite3.connect(db_path)
    ready = conn.execute("""
        SELECT id, platform, caption, image_path FROM scheduled_posts
        WHERE status = 'draft' AND scheduled_for <= datetime('now')
    """).fetchall()
    
    for post in ready:
        pid, platform, caption, image_path = post
        
        try:
            if platform == "facebook":
                result = publish_to_facebook(caption, image_path, "YOUR_PAGE_TOKEN", "YOUR_PAGE_ID")
            
            conn.execute("UPDATE scheduled_posts SET status = 'published', published_at = ? WHERE id = ?",
                        (datetime.utcnow().isoformat(), pid))
            print(f"Published to {platform}: {caption[:50]}...")
        except Exception as e:
            conn.execute("UPDATE scheduled_posts SET status = 'failed' WHERE id = ?", (pid,))
            print(f"Failed to publish to {platform}: {e}")
    
    conn.commit()
    conn.close()

Step 5: Schedule the Publisher

*/30 * * * * python3 /path/to/social_publisher.py
if __name__ == "__main__":
    init_social_db()
    process_scheduled_posts()

What to Build Next

Add a content review queue. Instead of auto-publishing, send draft posts to the agent via email or Slack for quick approval. One tap to approve, one tap to edit.

Related Reading

Want this system built for your business?

Get a free assessment. We will map every system your business needs and show you the ROI.

Get Your Free Assessment

Related Systems