Skip to main content
Every mile of deviation between a planned route and the actual route costs money — fuel, driver hours, and late deliveries. Most logistics teams review route performance manually, if they review it at all. Without a systematic comparison of planned versus actual, inefficiencies become invisible habits. Wayak connects your TMS and GPS data, runs Python-powered distance and time calculations in playbooks, and delivers route efficiency dashboards that highlight exactly where your network is losing money. The agent identifies deviations, classifies root causes, and recommends specific optimizations.

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
Semantic layer: Define these in your ontology before setting up the agent.
ComponentNameDefinition
ObjectRouteMaps to the TMS routes table. Represents a planned delivery route with its stops, miles, and time window
ObjectVehicleMaps to the fleet master table. Represents a truck or van with its capacity, cost rate, and driver assignment
MetricRouteDeviationPercentage difference between actual miles driven and planned miles: (actual - planned) / planned * 100
MetricCostPerMileTotal route cost (fuel + driver wages + vehicle depreciation) divided by actual miles driven
DimensionDeviationCauseCategorization: traffic, failed delivery attempt, incorrect stop sequence, unplanned stop, road closure
See building a semantic layer for a step-by-step guide.

Agent setup

1

Create the agent

Go to Agent SpaceNew agent.
FieldValue
NameRoute Optimizer
RoleDelivery route and fleet analyst
GoalMinimize delivery costs and transit times across the network
2

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.
3

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, Vehicle objects and RouteDeviation, CostPerMile metrics
4

Add skills

Trigger: User asks about route performance or daily route review
  1. Pull planned route data (miles, stops, time windows) and actual GPS data (miles driven, stop times, arrival times) for the specified period.
  2. Calculate route deviation percentage for each route: planned miles versus actual miles.
  3. Calculate time deviation: planned transit time versus actual transit time.
  4. Identify routes with more than 15% deviation on miles or time.
  5. For each deviation, classify the root cause using GPS stop data: traffic delay, failed delivery attempt, incorrect stop sequence, unplanned stop, or road closure.
  6. Calculate the cost impact of each deviation: excess miles multiplied by cost per mile.
  7. Output a route efficiency table ranked by cost impact, with a flag column for underperforming routes.
Trigger: User requests optimization suggestions or a route consistently underperforms
  1. Retrieve the historical performance data for the target route over the past 30 days.
  2. Identify the most frequent deviation causes and their average cost impact.
  3. Analyze stop sequence efficiency: calculate whether reordering stops would reduce total miles.
  4. Check delivery windows against historical traffic patterns to identify scheduling conflicts.
  5. Propose an optimized route with reordered stops, adjusted departure times, or alternative paths.
  6. Estimate the weekly savings if the optimization is adopted.

Automation

Playbook: Weekly route efficiency report

1

Set the trigger

Schedule: Every Monday at 7:00 AM.
2

Build the workflow

  1. Query the TMS for all completed routes in the previous 7 days.
  2. Query the GPS feed for actual miles, actual stop times, and arrival timestamps for each route.
  3. 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.
  4. 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.
  5. 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.
3

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.
4

Test and activate

Click Run now to test with live data, then toggle to Active.

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.