Fleet management platforms like Samsara and Geotab are data-rich but query-poor for non-technical users. While their SQL-based data warehouses (e.g., Samsara Data Insights API, Geotab Data Connector) store granular telematics on trips, harsh events, fuel usage, and engine diagnostics, extracting insights requires writing complex queries or waiting for pre-built reports. This integration layers a natural language interface directly on top of these data sources, allowing operations managers, safety directors, and finance leaders to ask questions like Which drivers had the most harsh braking events yesterday? or Show me the top 5 vehicles by fuel cost per mile this month. The system maps these questions to the underlying data model—translating driver to the Driver object, harsh braking to the Harsh Event type with a braking subtype, and yesterday to the appropriate timestamp filter in the platform's API or data lake.
Integration
Natural Language Queries for Fleet Analytics

From SQL to Natural Language: Democratizing Fleet Data
A technical guide to building a conversational AI layer on top of Samsara or Geotab data, enabling managers to query fleet performance in plain English.
Implementation involves a RAG (Retrieval-Augmented Generation) pipeline specifically tuned for fleet telematics. First, a semantic index is built from the platform's data schema, common KPIs, and historical query patterns. When a user asks a question, an LLM (like GPT-4 or Claude) decomposes it, identifies the relevant entities (vehicles, drivers, time ranges) and metrics (idle percentage, MPG, distance), and then constructs the appropriate API call or SQL query. For Samsara, this might target the /fleet/drivers and /fleet/harsh_events endpoints. For Geotab, it would generate a MyGeotab database query. The raw JSON or tabular results are then passed back to the LLM to be synthesized into a concise, natural language answer, with optional follow-up suggestions (e.g., Would you like to see a trend for this driver over the past quarter?). This can be deployed as a chatbot within the fleet platform's UI via iFrame or a custom tab, or as a standalone web application for dispatch centers.
Rollout requires careful governance and training. Start with a pilot group of power users in safety or operations, focusing on high-value, repetitive queries currently done manually. Implement query logging and review to catch misinterpretations (e.g., ambiguous terms like productivity which could mean miles driven or stops made) and refine the prompt chain. Access must be controlled via the fleet platform's existing RBAC; a dispatcher should only query data for their assigned vehicles. For production, build in audit trails that link each natural language query to the executed API call and the user who asked it, ensuring transparency for compliance. The final output is not just answers, but actionable workflows—clickable links to the specific driver scorecard in Samsara or the ability to automatically generate a coaching task in Motive based on the query's findings.
Where AI Connects: Platform Data Surfaces & APIs
Core Vehicle & Driver Data Streams
This is the primary fuel for natural language queries. AI models connect to APIs that stream or batch-retrieve granular telematics data. Key objects include:
- Trips & GPS Logs: Start/end times, route polyline, distance, and stop events. Used to answer questions like "show me all trips over 500 miles last week."
- Vehicle Stats: Engine hours, fuel consumption, odometer, and engine fault codes (DTCs). Enables queries on "which trucks are idling more than 2 hours daily?"
- Driver Behavior Events: Harsh acceleration, braking, cornering, and speeding incidents. Powers analysis of "which drivers had the most harsh events in rainy conditions?"
- IoT Sensor Data: Door open/close, PTO status, reefer temperatures, and trailer weight. Allows queries such as "show me all loads where the reefer temp exceeded 40°F."
Integrating here requires handling high-volume, time-series data via REST APIs or webhook streams, often needing aggregation before LLM context windows.
High-Value Use Cases for Conversational Fleet Analytics
Move beyond static dashboards. Embed a natural language layer into your Samsara, Geotab, or Motive data warehouse to let managers and dispatchers ask questions and get answers in seconds, not hours.
Real-Time Safety Exception Triage
Instead of sifting through hundreds of harsh event alerts, a safety manager asks: 'Show me all hard braking events from the last 4 hours for drivers with less than 6 months tenure, sorted by severity.' The AI agent queries telematics data, cross-references driver profiles, and returns a prioritized list with location maps and dash cam clip links for immediate review.
Driver Coaching Session Preparation
A safety director asks: 'What were the top 3 unsafe behaviors for driver ID 8472 last week, and show me comparative trends vs. the fleet average?' The system analyzes speeding, following distance, and cornering G-force data, generates a summary narrative, and pulls relevant video clips to build a data-driven, personalized coaching packet in minutes.
Fuel Spend Anomaly Investigation
A fleet analyst queries: 'Which vehicles had fuel economy more than 15% below their 90-day average in the last billing cycle? Correlate with idling time and route elevation changes.' The conversational layer joins fuel card transaction data with telematics streams, flags outliers, and suggests potential causes like defective sensors or unauthorized vehicle use.
Compliance Audit Documentation
Facing a DOT audit, a compliance officer asks: 'Compile a report for vehicle VIN 1XYZ123 showing all HOS violations, corresponding DVIR defects, and corrective actions taken in Q3.' The AI agent orchestrates queries across ELD logs, maintenance records, and driver communication logs, assembling a formatted, audit-ready document with source data citations.
Predictive Maintenance Triage
A maintenance supervisor asks: 'List all vehicles with active check engine lights, ordered by odometer reading. For each, show the last 3 similar fault codes and the mean time between failures for that component.' The system queries real-time fault code streams and historical repair orders, helping prioritize shop schedules and part ordering.
Route Efficiency Post-Mortem
After a delayed delivery, a dispatcher asks: 'Reconstruct the route for trip TR-8842. What were the top 3 causes of delay compared to the planned schedule?' The AI analyzes GPS breadcrumbs against traffic and weather historical data, identifying prolonged stops, route deviations, and traffic congestion to inform future planning and customer communications.
Example Workflows: From Question to Action
These workflows illustrate how a natural language query layer connects to your fleet data warehouse and triggers downstream actions within Samsara, Geotab, or your operational systems. Each example includes the technical trigger, data context, AI action, and resulting system update.
Trigger: A safety manager asks the question via a chat interface in the fleet operations dashboard.
Context/Data Pulled:
- The query is parsed, identifying intent (safety analysis), time range (this week), and grouping dimension (location).
- An agent calls the Samsara
safety/eventsAPI or GeotabStatusDatafeed for the specified date range, filtering for harsh braking, acceleration, and cornering events. - Driver and vehicle metadata is joined, and GPS coordinates for each event are reverse-geocoded to a nearest city or landmark.
Model/Agent Action:
- An LLM structures the raw event data into a summary table: Driver Name, Vehicle ID, Total Harsh Events, Most Common Event Type, Primary Location.
- The agent identifies the top 5 drivers by event count and generates a brief narrative: "Driver X had 7 harsh braking events, primarily on I-95 near Exit 89."
- It suggests a next step: "Generate a coaching assignment for these drivers?"
System Update/Next Step:
- The summary and table are displayed in the chat.
- The manager can approve the agent's suggestion, triggering an automated workflow that:
- Creates a new "Coaching Required" tag for the identified drivers in Samsara.
- Schedules a coaching session in the dispatcher's calendar (via Google Calendar API).
- Posts a notification to the relevant Slack/Teams channel for the safety team.
Human Review Point: The manager must approve the creation of driver tags and calendar invites before the system executes.
Implementation Architecture: Data Flow & AI Layer
A technical blueprint for adding a natural language query layer to Samsara or Geotab, enabling managers to ask operational questions directly against their fleet data warehouse.
The core architecture connects a Retrieval-Augmented Generation (RAG) pipeline to your fleet platform's data warehouse. For Samsara, this typically means querying the Samsara Data History API or a replicated data lake containing tables for vehicles, trips, engine_faults, and safety_events. For Geotab, the process involves the MyGeotab API or direct SQL access to the Geotab Drive Appliance database. The AI layer sits as a middleware service that: 1) parses a natural language question (e.g., 'show idling trends for my refrigerated trucks last week'), 2) translates it into the correct API calls or SQL queries using a tool-calling LLM, 3) executes the queries, and 4) uses a second LLM call to synthesize the raw JSON or tabular results into a concise, narrative answer. This service is often deployed as a containerized microservice that brokers secure access, manages API rate limits, and maintains an audit log of all queries and responses.
Critical implementation details involve context grounding to ensure accuracy. The system uses a vector store (like Pinecone or Weaviate) indexed with your fleet's specific metadata—vehicle names, driver IDs, custom group names, and report definitions—so the LLM understands your operational vocabulary. For example, the query 'Which drivers had the most harsh events yesterday?' must be mapped to the correct driverId field and the platform's specific definition of a 'harsh event' (e.g., a braking event over 0.45g in Samsara). The workflow is typically triggered via a chat interface embedded in a custom dashboard, a Slack/Microsoft Teams bot, or a voice assistant in a mobile driver app. Responses can be enhanced with visual previews by having the AI service also generate the parameters for a pre-built Samsara or Geotab report URL.
Rollout and governance require a phased approach. Start with a pilot group of power users (e.g., fleet analysts, safety managers) querying a read-only, time-bound dataset (e.g., last 30 days) to build trust in the system's accuracy. Implement guardrails such as query filters that prevent access to personally identifiable information (PII) without proper RBAC, and a human-in-the-loop review step for any AI-generated action items (like assigning coaching). Log all queries and model responses to a dedicated audit table for continuous evaluation and to retrain the query translation model on real user patterns. For production scaling, consider implementing a semantic cache to store and reuse the results of frequent, expensive queries (like daily fuel summaries) to reduce latency and API costs.
Code & Payload Examples
Querying Telematics via API & Grounding with RAG
This pattern fetches raw data from the fleet platform's API, then uses a Retrieval-Augmented Generation (RAG) pipeline to ground an LLM's response in the retrieved documents (e.g., trip summaries, event logs). The key is structuring the API query based on the user's natural language request.
pythonimport requests from inference_systems.llm_client import get_grounded_response # 1. Parse the natural language query user_query = "Which drivers had the most harsh braking events yesterday?" # 2. Translate to API parameters (pseudocode for Samsara/Geotab) api_params = { "start_time": "2024-01-15T00:00:00Z", "end_time": "2024-01-15T23:59:59Z", "metrics": ["harsh_braking_count"], "group_by": ["driver_id"] } # 3. Fetch data from fleet platform API response = requests.get( "https://api.samsara.com/fleet/driver/safety-events", headers={"Authorization": "Bearer YOUR_API_KEY"}, params=api_params ) raw_events = response.json()["data"] # 4. Format retrieved data as context for RAG context_docs = [ f"Driver {e['driver']['name']} (ID: {e['driver']['id']}) had {e['harshBraking']['count']} harsh braking events on {e['startTime']}." for e in raw_events ] # 5. Get grounded, natural language answer answer = get_grounded_response( query=user_query, context=context_docs, instruction="Summarize the findings clearly for a fleet manager." ) # Output: "Yesterday, Driver Smith had 3 harsh braking events, Driver Jones had 2..."
Realistic Time Savings & Operational Impact
How adding a conversational AI layer to platforms like Samsara or Geotab changes the speed and depth of operational analysis for fleet managers.
| Analytical Task | Before AI | After AI | Implementation Notes |
|---|---|---|---|
Driver Safety Trend Analysis | Manual export to BI tool, 2-4 hours per week | Natural language query, results in <2 minutes | Direct query of telematics warehouse via RAG; human review of insights remains. |
Root Cause for Harsh Event Spikes | Cross-reference dash cam clips & location logs, 1-2 hours per incident | AI correlates events, weather, and location; summary in 5 minutes | AI agent calls multiple APIs (telematics, weather) and synthesizes a narrative. |
Fuel Efficiency Report by Vehicle Class | Build custom report in platform UI, 30-60 minutes | Ask 'Show me MPG trends for tractors vs. vans last quarter', <1 minute | Generates SQL or API calls from natural language; outputs to dashboard or email. |
Identifying Top Idling Offenders | Sort and filter in platform, 15-20 minutes daily | Real-time alert or daily digest via scheduled query | AI monitors live data streams; can trigger automated coaching workflows. |
Custom KPI Dashboard Creation | Require IT/analyst support, 1-2 week lead time | Describe needs in plain text, prototype in hours | AI suggests visualizations and data sources; final human configuration required. |
Post-Trip Documentation & Summary | Manager reviews trip history manually, 10-15 min per driver | AI generates trip summary with highlights/concerns, <1 minute | Integrates with DVIR and ELD data; summary appended to driver record. |
Audit Preparation for Compliance | Manual compilation of logs and reports, 8-16 hours per audit | AI assembles evidence pack from specified date range, 1-2 hours | Pulls from disparate system logs; human must verify completeness and submit. |
Governance, Security & Phased Rollout
A secure, governed approach to deploying conversational AI over your fleet data warehouse.
A production-ready natural language query system requires a secure middleware layer that sits between your fleet data warehouse (e.g., Samsara Data Export or Geotab MyGeotab) and the LLM. This layer handles query translation, data retrieval, and prompt security. Key architectural components include:
- API Gateway & Authentication: All queries route through a secure gateway that validates user credentials against your existing IdP (Okta, Entra ID) and enforces role-based access to data objects (e.g., a safety manager can query harsh events, but not driver payroll data).
- Query Intent Classifier: An initial model or rule set that classifies the user's question (e.g., 'fuel usage' vs. 'driver safety') and routes it to the correct data source or pre-built SQL template.
- Parameterized SQL Generation: Instead of letting an LLM write free-form SQL, the system uses a library of approved, parameterized queries. The LLM's role is to extract the correct parameters (driver name, date range, vehicle ID) and populate the safe template, preventing SQL injection and data scope violations.
- Audit Logging: Every query, its parameters, the user who asked it, and the data scope accessed is logged immutably for compliance and usage analytics.
Rollout should follow a phased, risk-managed approach, starting with read-only analytics for a pilot group.
Phase 1: Pilot (Controlled Read-Only)
- User Group: Select fleet analysts and operations managers.
- Data Scope: Historical data only, from a single source (e.g., Samsara). Queries limited to non-sensitive KPIs: idling hours, trip counts, harsh event summaries.
- Workflow: All query responses include a citation of the underlying data source and timestamp. A human-in-the-loop review step is required for the first 100 queries to validate accuracy.
- Integration Point: Deploy the query service as a standalone web app or a Slack/Microsoft Teams bot, pulling data via the fleet platform's REST API.
Phase 2: Production (Expanded Access)
- User Group: All managers and dispatchers.
- Data Scope: Near-real-time data, blended sources (e.g., combine Samsara telematics with fuel card data). Introduce more complex queries involving driver performance trends and route efficiency.
- Workflow: Automated responses for pre-validated query patterns. Introduce a feedback mechanism where users can flag inaccurate answers to continuously improve the query templates.
- Integration Point: Embed the query interface directly into the fleet platform's dashboard using custom widgets or iFrames, providing a seamless user experience.
Governance is critical for maintaining trust and compliance. Establish a cross-functional oversight committee (Operations, IT, Data, Compliance) to:
- Approve New Query Templates: Any new question type requires a review of the SQL logic, data sources, and user permissions before being added to the production library.
- Monitor for Data Drift: Regularly check that the underlying data schemas from Samsara or Geotab haven't changed, which could break query templates.
- Conduct Periodic Access Reviews: Audit user roles and query logs to ensure access patterns align with job functions.
- Manage LLM Costs & Performance: Implement caching for frequent queries (e.g., 'yesterday's top 5 drivers by harsh events') and set usage limits per user to control API costs.
By treating natural language as a new query interface to your governed data, not a black-box AI feature, you gain the productivity benefits of conversational analytics while maintaining the security and auditability required for enterprise fleet operations.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Frequently Asked Questions
Practical questions for technical teams building a natural language query layer on top of Samsara, Geotab, or Motive data warehouses.
A production architecture typically involves three layers:
- Data & Indexing Layer: A scheduled pipeline (e.g., Airflow, dbt) extracts aggregated trip, safety, and vehicle data from your fleet platform's API or data warehouse (Samsara Data Insights, Geotab Data Warehouse). This data is transformed into clean, summarized datasets and embedded into a vector database like Pinecone or Weaviate.
- Orchestration & Query Layer: An application server (FastAPI, Node.js) hosts the LLM orchestration logic. It:
- Accepts a natural language query ("Which drivers had the most harsh events yesterday?").
- Uses a retrieval-augmented generation (RAG) pattern to search the vector index for relevant context (e.g., yesterday's harsh event summaries by driver).
- Constructs a precise prompt with the retrieved data and sends it to an LLM (OpenAI GPT-4, Anthropic Claude).
- Parses the LLM's structured response (often JSON) for accuracy.
- Interface & Delivery Layer: The answer is returned via a chat UI (Slack, Microsoft Teams), embedded dashboard widget, or API response. For auditability, all queries, retrieved context, and generated answers are logged.
Key integration points are the fleet platform's Reporting API for batch data and the Webhooks API for real-time context if needed.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us