📋 Optimize delivery routes for carriers from Google Sheets using Google Maps
⚡ 123 views · 📋 Project Management
Description
This workflow automates the process of converting delivery addresses into geographic coordinates and optimizes delivery routes for each carrier using Google Maps.
Finally, the workflow outputs an optimized circular route that starts and ends at the base location.
This workflow is particularly useful for:
- Logistics companies
- Courier services
- Delivery businesses
- Field service operations
- Fleet management teams
It enables faster route planning, improves delivery efficiency, and provides a low-code automation solution that integrates directly with existing operational spreadsheets.
Key Advantages
1. ✅ Automated Address Geocoding
The workflow automatically converts delivery addresses into precise GPS coordinates using Google Maps APIs, eliminating manual data entry and reducing human errors.
2. ✅ Delivery Route Optimization
By calculating the most efficient delivery order, the workflow helps drivers reduce travel time, fuel consumption, and operational costs.
3. ✅ Seamless Google Sheets Integration
All delivery data is managed directly inside Google Sheets, making the system easy to use for logistics teams without requiring additional software.
4. ✅ Carrier-Based Delivery Grouping
Deliveries are automatically grouped by carrier, allowing each driver or logistics operator to receive a dedicated optimized route.
5. ✅ Real-Time Data Processing
The workflow dynamically processes only the deliveries scheduled for the current day, ensuring routes are always updated and relevant.
6. ✅ Scalable and Flexible
The solution can easily scale to handle larger delivery volumes and can be adapted for different logistics operations, territories, or business models.
7. ✅ Reduced Operational Costs
Optimized routes reduce unnecessary mileage, helping companies lower fuel expenses, vehicle wear, and delivery times.
8. ✅ Intelligent Distance Calculation
The workflow uses Google Routes API for accurate driving distances and includes fallback logic to ensure continuity even if API responses fail.
9. ✅ Fully Automated Workflow
Once configured, the entire process runs automatically with minimal manual intervention, improving productivity and operational reliability.
10. ✅ Easy Customization
The workflow can be customized to support:
- Multiple warehouses
- Dynamic starting points
- Additional delivery constraints
- Traffic-aware routing
- Advanced optimization strategies
How it works
-
Manual trigger
The workflow starts manually by clicking “Execute workflow”. -
Fetch today’s deliveries
- Reads from a Google Sheet.
- Filters rows where
DATE DELIVERYequals today’s date.
-
Geocode each delivery address
- Loops through each delivery row.
- Calls the Google Maps Places API (textsearch) to get latitude and longitude.
- Updates the sheet’s
LANGandLONGcolumns. - Marks
DONE = "x"to avoid reprocessing.
-
Get start address location
- A fixed start address (e.g., warehouse) is geocoded once.
- Stores
START ADDRESS,START LAT,START LNG.
-
Filter already processed deliveries
- Reads the sheet again, filtering for today’s date and
DONE = "x". - These are fully geocoded deliveries ready for routing.
- Reads the sheet again, filtering for today’s date and
-
Group deliveries by carrier
- Groups all delivery rows by
NAME CARRIER.
- Groups all delivery rows by
-
Optimize route for each carrier
- Runs a custom JavaScript routing algorithm:
- Uses Google Routes API for real driving distances.
- Implements a nearest neighbor heuristic + 2-opt optimization.
- Computes a circular route starting/ending at the warehouse.
- Outputs an ordered list of stops including the warehouse as start and end.
- Runs a custom JavaScript routing algorithm:
-
Return optimized route
- The final route is returned as structured JSON.
- Can be further used for writing back to Sheets or displaying.
Set up steps
-
Google Sheets setup
- Create a Google Sheet with columns:
row_number,NAME CARRIER,DATE DELIVERY,ADDRESS,LANG,LONG,DONE. - Clone the example sheet.
- Note the
documentIdfrom the sheet’s URL.
- Create a Google Sheet with columns:
-
Google Sheets OAuth2 credentials
- In n8n, add a Google Sheets OAuth2 API credential.
- Use the same email that owns/edits the sheet.
-
Google Maps API credentials
- Enable Places API and Routes API in Google Cloud Console.
- Create an API key with no restrictions or restrict it to the required APIs.
- In n8n, add an HTTP Query Auth credential:
- Key:
key - Value: your Google Maps API key.
- Key:
-
Update workflow configuration
- In the Google Sheets nodes (
Get date delivery,Update Lat and Lng,Get addresses), replace thedocumentIdwith your own sheet ID. - Ensure the sheet name (
Foglio1orgid=0) matches.
- In the Google Sheets nodes (
-
Set start address
- In the Start address node (
n8n-nodes-base.set), edit theSTART ADDRESSassignment to your warehouse/starting location.
- In the Start address node (
-
Adjust wait time
- The Wait node is set to 10 seconds to respect Google Maps API rate limits. Adjust if needed.
-
Run the workflow
- Click “When clicking ‘Execute workflow’” button in n8n.
- The workflow geocodes new addresses, updates the sheet, and outputs an optimized route per carrier.
👉 Subscribe to my new YouTube channel. Here I’ll share videos and Shorts with practical tutorials and FREE templates for n8n.
Need help customizing?
Contact me for consulting and support or add me on Linkedin.
🔗 Nodes Used
Google Sheets, HTTP Request, Schedule Trigger
📥 Import
Download workflow.json and import into n8n:
Workflow menu → Import from File
