By Sagar Shankaran, Founder of CallSphere
Build an AI agent that monitors fleet vehicles via GPS integration, enforces maintenance schedules based on mileage and time rules, and sends alerts to drivers and fleet managers automatically.
Key takeaways
Fleet operators with 50 to 5,000 vehicles face a constant operational balancing act. Every vehicle needs regular oil changes, tire rotations, brake inspections, and DOT compliance checks. Drivers need route updates, maintenance reminders, and emergency support. Managers need visibility into where every vehicle is, which ones are due for service, and which drivers are approaching hours-of-service limits.
An AI agent for fleet management ties together GPS telematics, maintenance rule engines, and communication channels into a single conversational interface that fleet managers and dispatchers can query naturally.
Start with data models that capture vehicle state and maintenance requirements:
Hear it before you finish reading
Talk to a live CallSphere AI voice agent for logistics in your browser — 60 seconds, no signup.
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, field
from datetime import datetime, date
from enum import Enum
from typing import Optional
class MaintenanceType(str, Enum):
OIL_CHANGE = "oil_change"
TIRE_ROTATION = "tire_rotation"
BRAKE_INSPECTION = "brake_inspection"
DOT_INSPECTION = "dot_inspection"
TRANSMISSION_SERVICE = "transmission_service"
@dataclass
class MaintenanceRule:
maintenance_type: MaintenanceType
interval_miles: int
interval_days: int
description: str
@dataclass
class FleetVehicle:
vehicle_id: str
unit_number: str
make: str
model: str
year: int
current_mileage: int
last_oil_change_miles: int
last_oil_change_date: date
latitude: float
longitude: float
speed_mph: float
driver_name: str
driver_phone: str
status: str = "active"
MAINTENANCE_RULES = [
MaintenanceRule(MaintenanceType.OIL_CHANGE, 7500, 180, "Engine oil and filter"),
MaintenanceRule(MaintenanceType.TIRE_ROTATION, 10000, 365, "Rotate all tires"),
MaintenanceRule(MaintenanceType.BRAKE_INSPECTION, 25000, 365, "Full brake check"),
MaintenanceRule(MaintenanceType.DOT_INSPECTION, 0, 365, "Annual DOT compliance"),
]
The vehicle tracking tool simulates pulling real-time location data from a telematics provider like Samsara, Geotab, or Verizon Connect:
from agents import function_tool
FLEET_VEHICLES = [
FleetVehicle("FV-001", "Unit 14", "Freightliner", "Cascadia", 2024,
142000, 135000, date(2025, 11, 15), 37.7749, -122.4194,
58.0, "Mike Torres", "+1-555-0101"),
FleetVehicle("FV-002", "Unit 27", "Kenworth", "T680", 2023,
198000, 195500, date(2026, 1, 20), 34.0522, -118.2437,
0.0, "Sarah Kim", "+1-555-0102"),
FleetVehicle("FV-003", "Unit 33", "Volvo", "VNL 860", 2025,
67000, 62000, date(2025, 12, 10), 41.8781, -87.6298,
62.5, "James Okafor", "+1-555-0103"),
]
@function_tool
def get_vehicle_location(unit_number: Optional[str] = None) -> str:
"""Get current GPS location and status for fleet vehicles."""
vehicles = FLEET_VEHICLES
if unit_number:
vehicles = [v for v in vehicles
if v.unit_number.lower() == unit_number.lower()]
if not vehicles:
return "No matching vehicles found."
lines = []
for v in vehicles:
status = "Moving" if v.speed_mph > 0 else "Stopped"
lines.append(
f"{v.unit_number} ({v.year} {v.make} {v.model}) | "
f"Driver: {v.driver_name} | "
f"Location: ({v.latitude:.4f}, {v.longitude:.4f}) | "
f"Speed: {v.speed_mph} mph | Status: {status}"
)
return "\n".join(lines)
This tool evaluates each vehicle against the maintenance rules and flags overdue or upcoming services:
@function_tool
def check_maintenance_status(unit_number: Optional[str] = None) -> str:
"""Check maintenance status for fleet vehicles based on mileage and time rules."""
vehicles = FLEET_VEHICLES
if unit_number:
vehicles = [v for v in vehicles
if v.unit_number.lower() == unit_number.lower()]
today = date.today()
alerts = []
for v in vehicles:
for rule in MAINTENANCE_RULES:
miles_since = v.current_mileage - v.last_oil_change_miles
days_since = (today - v.last_oil_change_date).days
overdue_miles = (rule.interval_miles > 0
and miles_since >= rule.interval_miles)
overdue_days = days_since >= rule.interval_days
if overdue_miles or overdue_days:
reason = []
if overdue_miles:
reason.append(f"{miles_since} miles since last service")
if overdue_days:
reason.append(f"{days_since} days since last service")
alerts.append(
f"OVERDUE: {v.unit_number} needs {rule.description} "
f"({', '.join(reason)})"
)
return "\n".join(alerts) if alerts else "All vehicles are current on maintenance."
@function_tool
def send_driver_message(
unit_number: str,
message: str,
priority: str = "normal",
) -> str:
"""Send a message to a fleet driver via their registered phone number."""
vehicle = next(
(v for v in FLEET_VEHICLES
if v.unit_number.lower() == unit_number.lower()), None
)
if not vehicle:
return f"Vehicle {unit_number} not found in fleet."
# In production, call Twilio / SMS API here
return (
f"Message sent to {vehicle.driver_name} ({vehicle.driver_phone}): "
f"[{priority.upper()}] {message}"
)
from agents import Agent, Runner
fleet_agent = Agent(
name="Fleet Manager",
instructions="""You are an AI fleet management assistant. You can:
1. Track vehicle locations and speeds in real time
2. Check maintenance schedules and flag overdue services
3. Send messages to drivers with normal or urgent priority
Always prioritize safety-related maintenance alerts.""",
tools=[get_vehicle_location, check_maintenance_status, send_driver_message],
)
result = Runner.run_sync(
fleet_agent,
"Which vehicles have overdue maintenance? Notify those drivers."
)
print(result.final_output)
Most providers like Samsara, Geotab, and KeepTruckin offer REST APIs. Replace the in-memory fleet list with API calls that fetch live vehicle positions. Use webhook subscriptions for real-time event streaming instead of polling, and cache location data for 30 to 60 seconds to reduce API costs.
Still reading? Stop comparing — try CallSphere live.
See the logistics AI agent handle a real call — complete, industry-specific, and live in your browser. No signup.
Yes. Add a tool that queries ELD (Electronic Logging Device) data for each driver. The tool checks remaining drive time, mandatory break requirements, and 70-hour weekly limits. If a driver approaches a threshold, the agent can proactively alert dispatch to plan a relief driver or rest stop.
In production, integrate with a shop management system that tracks bay availability and technician schedules. The agent should check open slots before scheduling and offer the driver the nearest available time. Use optimistic locking on appointment slots to prevent double-booking.
#FleetManagement #VehicleTracking #MaintenanceAI #Logistics #Python #AgenticAI #LearnAI #AIEngineering

Written by
Sagar Shankaran· Founder, CallSphere
LinkedInSagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
A practical guide for Senegalese logistics, freight, legal and consulting SMBs in Dakar and Thiès to capture every enquiry 24/7 with a CallSphere AI voice and chat agent in French, Wolof and English.
A pain-to-solution guide for logistics operators and professional-services firms across Poland, Czechia, Hungary and Slovakia to capture cross-border calls 24/7 with a CallSphere AI agent.
Freight forwarders, clearing agents and transport firms around Owendo and Port-Gentil use CallSphere AI agents to answer shipper and driver calls 24/7 in French, Fang and English, and keep every consignment moving.
Kyrgyz freight forwarders, Dordoi traders, and Middle Corridor logistics firms field calls at all hours. CallSphere answers 24/7 in Kyrgyz, Russian, and English and captures every shipment enquiry.
Freight forwarders, clearing agents, and logistics firms around the Port of Djibouti and Doraleh use CallSphere AI agents to answer French, Somali, Arabic, and English calls 24/7 and never miss a shipment enquiry.
Dutch logistics, retail and hospitality businesses in Rotterdam, Amsterdam and Eindhoven lose bookings and orders to unanswered phones. See how CallSphere AI voice and chat agents capture every call 24/7 in Dutch and English, GDPR-compliant.
© 2026 CallSphere Inc. All rights reserved.
Made within San Francisco
Watch how CallSphere handles real customer calls, schedules appointments, and processes payments — live.