What you need
Data sources
- TMS database — Planned routes table with origin, destination, planned stops, planned miles, planned time, and assigned vehicle
- GPS/telematics feed — Actual vehicle positions, timestamps, stop durations, and actual miles driven
Knowledge spaces
- Routing guidelines — Standard operating procedures for route planning, maximum drive times, and delivery window rules
- Customer delivery requirements — Specific delivery windows, access instructions, and appointment scheduling rules by customer
| Component | Name | Definition |
|---|---|---|
| Object | Route | Maps to the TMS routes table. Represents a planned delivery route with its stops, miles, and time window |
| Object | Vehicle | Maps to the fleet master table. Represents a truck or van with its capacity, cost rate, and driver assignment |
| Metric | RouteDeviation | Percentage difference between actual miles driven and planned miles: (actual - planned) / planned * 100 |
| Metric | CostPerMile | Total route cost (fuel + driver wages + vehicle depreciation) divided by actual miles driven |
| Dimension | DeviationCause | Categorization: traffic, failed delivery attempt, incorrect stop sequence, unplanned stop, road closure |
Agent setup
Create the agent
Go to Agent Space → New agent.
| Field | Value |
|---|---|
| Name | Route Optimizer |
| Role | Delivery route and fleet analyst |
| Goal | Minimize delivery costs and transit times across the network |
Set the description
You optimize delivery routes and fleet utilization. When analyzing routes, always factor in distance, traffic patterns, delivery windows, vehicle capacity, and driver hours. Present route recommendations as comparisons — show the current route versus the optimized route with estimated savings. Use precise metrics (miles, hours, dollars). Flag any delivery at risk of missing its window. Never recommend routes that violate driver hours-of-service regulations.
Scope data access
Grant access to:
- TMS database (routes, shipments, stops)
- GPS/telematics feed (vehicle positions, actual miles)
- Routing guidelines knowledge space
- Customer delivery requirements knowledge space
Route,Vehicleobjects andRouteDeviation,CostPerMilemetrics
Add skills
Calculate route efficiency
Calculate route efficiency
Trigger: User asks about route performance or daily route review
- Pull planned route data (miles, stops, time windows) and actual GPS data (miles driven, stop times, arrival times) for the specified period.
- Calculate route deviation percentage for each route: planned miles versus actual miles.
- Calculate time deviation: planned transit time versus actual transit time.
- Identify routes with more than 15% deviation on miles or time.
- For each deviation, classify the root cause using GPS stop data: traffic delay, failed delivery attempt, incorrect stop sequence, unplanned stop, or road closure.
- Calculate the cost impact of each deviation: excess miles multiplied by cost per mile.
- Output a route efficiency table ranked by cost impact, with a flag column for underperforming routes.
Recommend route optimization
Recommend route optimization
Trigger: User requests optimization suggestions or a route consistently underperforms
- Retrieve the historical performance data for the target route over the past 30 days.
- Identify the most frequent deviation causes and their average cost impact.
- Analyze stop sequence efficiency: calculate whether reordering stops would reduce total miles.
- Check delivery windows against historical traffic patterns to identify scheduling conflicts.
- Propose an optimized route with reordered stops, adjusted departure times, or alternative paths.
- Estimate the weekly savings if the optimization is adopted.
Automation
Playbook: Weekly route efficiency report
Build the workflow
- Query the TMS for all completed routes in the previous 7 days.
- Query the GPS feed for actual miles, actual stop times, and arrival timestamps for each route.
- Run Python analysis to calculate:
- Route deviation percentage for each route.
- Total excess miles and excess cost across the fleet.
- Deviation cause classification using GPS stop patterns.
- Week-over-week trend in average route efficiency.
- Condition: If total excess cost exceeds $5,000 for the week, flag the report as “action required” and highlight the top 5 most costly routes.
- Aggregate into a formatted report: fleet-level summary, route-level detail table, and trend chart.
The distance and cost calculation step uses a Python code block to compute great-circle distances between GPS waypoints, aggregate excess miles, and multiply by the per-mile cost rate. You can customize the cost rate and deviation thresholds in the code.
Configure delivery
Send an email to the logistics operations manager with the subject line: “Weekly route efficiency — [date]”. Include the fleet summary at the top and the route detail table below. Post a summary to the
#fleet-ops Slack channel.What’s next
Delivery exception management
Catch the exceptions that cause route deviations before they cascade across your network.
All logistics use cases
See the full list.

