Skip to content
Building a Car Dealership AI Agent: Inventory Search, Test Drive Scheduling, and Finance Quotes
Learn Agentic AI14 min read7 views

Building a Car Dealership AI Agent: Inventory Search, Test Drive Scheduling, and Finance Quotes

Learn how to build an AI agent for car dealerships that searches vehicle inventory, schedules test drives, and generates finance quotes using tool-calling patterns and structured vehicle databases.

Why Car Dealerships Need AI Agents

Car dealerships handle thousands of customer inquiries every week. Shoppers want to know if a specific model is in stock, whether they can test drive it Saturday afternoon, and what their monthly payment would be on a 60-month loan. Traditionally these questions get routed to salespeople who manually search DMS (Dealer Management System) databases, check calendars, and run finance calculators.

An AI agent can handle the entire pre-sales workflow: searching inventory by make, model, year, color, and price range; booking test drive appointments against availability; and generating personalized finance estimates based on credit tier and down payment. The agent connects to real dealership data through tools and returns accurate, structured answers in seconds.

Designing the Vehicle Database Schema

A dealership inventory system needs to capture vehicle details, pricing, and availability status. Here is a practical schema:

flowchart LR
    INPUT(["User intent"])
    PARSE["Parse plus<br/>classify"]
    PLAN["Plan and tool<br/>selection"]
    AGENT["Agent loop<br/>LLM plus tools"]
    GUARD{"Guardrails<br/>and policy"}
    EXEC["Execute and<br/>verify result"]
    OBS[("Trace and metrics")]
    OUT(["Outcome plus<br/>next action"])
    INPUT --> PARSE --> PLAN --> AGENT --> GUARD
    GUARD -->|Pass| EXEC --> OUT
    GUARD -->|Fail| AGENT
    AGENT --> OBS
    style AGENT fill:#4f46e5,stroke:#4338ca,color:#fff
    style GUARD fill:#f59e0b,stroke:#d97706,color:#1f2937
    style OBS fill:#ede9fe,stroke:#7c3aed,color:#1e1b4b
    style OUT fill:#059669,stroke:#047857,color:#fff
from dataclasses import dataclass
from enum import Enum
from typing import Optional

class VehicleStatus(str, Enum):
    AVAILABLE = "available"
    ON_HOLD = "on_hold"
    SOLD = "sold"
    IN_TRANSIT = "in_transit"

@dataclass
class Vehicle:
    stock_number: str
    vin: str
    year: int
    make: str
    model: str
    trim: str
    exterior_color: str
    interior_color: str
    mileage: int
    msrp: float
    selling_price: float
    status: VehicleStatus
    features: list[str]
    image_url: Optional[str] = None

In production, this data lives in the DMS. For our agent, we expose it through search tools that query the database with filters.

Hear it before you finish reading

Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.

Try Live Demo →

Building the Inventory Search Tool

The search tool accepts flexible criteria and returns matching vehicles ranked by relevance:

from agents import Agent, Runner, function_tool
from typing import Optional

VEHICLE_INVENTORY = [
    Vehicle("STK-1001", "1HGCG5655WA123456", 2026, "Honda", "Accord",
            "Sport", "Platinum White", "Black", 12, 33500.00, 32200.00,
            VehicleStatus.AVAILABLE, ["Sunroof", "Heated Seats", "CarPlay"]),
    Vehicle("STK-1002", "5YJSA1E26MF123789", 2026, "Tesla", "Model 3",
            "Long Range", "Midnight Silver", "White", 0, 42990.00, 42990.00,
            VehicleStatus.AVAILABLE, ["Autopilot", "Premium Audio"]),
    Vehicle("STK-1003", "2T1BURHE0KC987654", 2025, "Toyota", "Camry",
            "XSE", "Celestial Silver", "Red", 8500, 31500.00, 29800.00,
            VehicleStatus.AVAILABLE, ["TRD Package", "Panoramic Roof"]),
]

@function_tool
def search_inventory(
    make: Optional[str] = None,
    model: Optional[str] = None,
    min_year: Optional[int] = None,
    max_price: Optional[float] = None,
    color: Optional[str] = None,
) -> str:
    """Search dealership vehicle inventory by make, model, year, price, or color."""
    results = [v for v in VEHICLE_INVENTORY if v.status == VehicleStatus.AVAILABLE]

    if make:
        results = [v for v in results if v.make.lower() == make.lower()]
    if model:
        results = [v for v in results if v.model.lower() == model.lower()]
    if min_year:
        results = [v for v in results if v.year >= min_year]
    if max_price:
        results = [v for v in results if v.selling_price <= max_price]
    if color:
        results = [v for v in results
                   if color.lower() in v.exterior_color.lower()]

    if not results:
        return "No vehicles found matching your criteria."

    lines = []
    for v in results:
        lines.append(
            f"{v.year} {v.make} {v.model} {v.trim} | {v.exterior_color} | "
            f"{v.mileage} mi | ${v.selling_price:,.0f} | Stock: {v.stock_number}"
        )
    return "\n".join(lines)

Test Drive Scheduling Tool

The scheduling tool checks availability windows and books appointments:

from datetime import datetime, timedelta

BOOKED_SLOTS: dict[str, list[str]] = {}

@function_tool
def schedule_test_drive(
    stock_number: str,
    customer_name: str,
    preferred_date: str,
    preferred_time: str,
) -> str:
    """Schedule a test drive for a specific vehicle."""
    try:
        dt = datetime.strptime(
            f"{preferred_date} {preferred_time}", "%Y-%m-%d %H:%M"
        )
    except ValueError:
        return "Invalid date/time format. Use YYYY-MM-DD and HH:MM."

    if dt < datetime.now():
        return "Cannot book a test drive in the past."

    if dt.weekday() == 6:
        return "Dealership is closed on Sundays."

    slot_key = dt.strftime("%Y-%m-%d %H:%M")
    day_key = dt.strftime("%Y-%m-%d")

    if day_key in BOOKED_SLOTS and slot_key in BOOKED_SLOTS[day_key]:
        return f"The {slot_key} slot is already booked. Try 30 minutes later."

    BOOKED_SLOTS.setdefault(day_key, []).append(slot_key)
    return (
        f"Test drive confirmed for {customer_name}: "
        f"{stock_number} on {slot_key}. Please bring a valid driver's license."
    )

Finance Quote Tool

The finance calculator computes monthly payments using standard amortization:

@function_tool
def calculate_finance_quote(
    vehicle_price: float,
    down_payment: float,
    term_months: int = 60,
    annual_rate: float = 6.5,
) -> str:
    """Calculate monthly payment for a vehicle purchase."""
    loan_amount = vehicle_price - down_payment
    if loan_amount <= 0:
        return "Down payment covers the full vehicle price. No financing needed."

    monthly_rate = (annual_rate / 100) / 12
    payment = loan_amount * (
        monthly_rate * (1 + monthly_rate) ** term_months
    ) / ((1 + monthly_rate) ** term_months - 1)

    return (
        f"Vehicle Price: ${vehicle_price:,.0f}\n"
        f"Down Payment: ${down_payment:,.0f}\n"
        f"Loan Amount: ${loan_amount:,.0f}\n"
        f"Term: {term_months} months at {annual_rate}% APR\n"
        f"Monthly Payment: ${payment:,.2f}"
    )

Assembling the Dealership Agent

dealership_agent = Agent(
    name="Dealership Assistant",
    instructions="""You are a helpful car dealership assistant. Help customers:
    1. Search for vehicles by make, model, year, price, or color
    2. Schedule test drives for available vehicles
    3. Calculate finance quotes with different down payments and terms
    Always be friendly and transparent about pricing.""",
    tools=[search_inventory, schedule_test_drive, calculate_finance_quote],
)

result = Runner.run_sync(
    dealership_agent,
    "I'm looking for a white sedan under $35,000. Can I test drive one Saturday at 2pm?"
)
print(result.final_output)

The agent will search inventory, find the Honda Accord, and offer to book the test drive in a single conversational turn.

Still reading? Stop comparing — try CallSphere live.

CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.

FAQ

How do I connect this to a real DMS like DealerSocket or CDK?

Replace the in-memory inventory list with API calls to your DMS provider. Most modern DMS platforms offer REST APIs. Wrap each API call in a tool function that handles authentication, pagination, and error responses. Cache inventory data with a short TTL to reduce API calls.

Can the agent handle trade-in valuations?

Yes. Add a tool that accepts the customer's trade-in VIN and mileage, then calls a valuation API like Kelley Blue Book or Black Book to return an estimated value. Subtract the trade-in value from the vehicle price before calculating the finance quote.

How do I prevent double-booking test drives?

In production, use a database-backed appointment system with row-level locking or optimistic concurrency control. Check availability inside a transaction and insert the booking atomically. The in-memory approach shown here is for demonstration only.


#AutomotiveAI #CarDealership #InventoryManagement #AIAgents #Python #AgenticAI #LearnAI #AIEngineering

Share

Try CallSphere AI Voice Agents

See how AI voice agents work for your industry. Live demo available -- no signup required.

Related Articles You May Like

AI Agents

Personal AI Assistant: How to Pick One for Business in 2026

A founder's guide to the personal AI assistant market: best AI assistant apps, business-grade options, and how CallSphere's voice agent fits in.

AI Agents

Free AI Agents in 2026: When Free Wins and When It Costs You

A founder's guide to free AI agents, low-code AI agent builders, and how to know when you should pay for a real platform like CallSphere.

Agentic AI

Graphiti: How Temporal Knowledge Graphs Give AI Voice Agents Persistent Memory (2026 Guide)

Graphiti is the open-source temporal knowledge graph for AI agents in 2026. Learn how bi-temporal memory beats vector RAG for voice agents and long-running LLMs.

AI Agents

Chatbot App vs ChatGPT: What's the Difference, and Which Do I Need?

Chatbot app vs ChatGPT in 2026: a founder's clear take on the difference, when to use which, and how a real AI chatbot app development works.

HVAC

Building an HVAC After-Hours Emergency Escalation System: A Complete Engineering Guide

How we built a fault-tolerant HVAC emergency triage and tech-dispatch platform on Kubernetes — three-tier CQRS, 11 micro-agents on the OpenAI Agents SDK + LangGraph, NATS JetStream, DTMF/SMS/WebSocket acceptance, circuit breakers, and an evaluation pipeline that catches regressions before they wake a tech at 3 AM.

Enterprise AI

OpenAI Frontier vs Anthropic Managed Agents: 2026 Comparison

Head-to-head: OpenAI Frontier and Anthropic's managed agent stack — strengths, fit, and what each means for enterprise AI voice and chat deployment.