Skip to main content

Optimize delivery routes for carriers from Google Sheets using Google Maps

Workflow preview

Workflow preview
100%
Optimize delivery routes for carriers from Google Sheets using Google Maps preview
Open on n8n.io

1. Workflow Overview

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

Best for

  • Project Management automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.manualtrigger, n8n-nodes-base.splitinbatches, n8n-nodes-base.wait, n8n-nodes-base.merge, n8n-nodes-base.stickynote, n8n-nodes-base.googlesheets, n8n-nodes-base.httprequest, n8n-nodes-base.set

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Davide Boizza.

Original n8n.io source

1.1 Workflow description

Title
Optimize delivery routes for carriers from Google Sheets using Google Maps
Workflow name
Optimize delivery routes for carriers from Google Sheets using Google Maps

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

  1. Manual trigger The workflow starts manually by clicking "Execute workflow".

  2. Fetch today’s deliveries

  • Reads from a Google Sheet.
  • Filters rows where DATE DELIVERY equals today’s date.
  1. 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 LANG and LONG columns.
  • Marks DONE = "x" to avoid reprocessing.
  1. Get start address location
  • A fixed start address (e.g., warehouse) is geocoded once.
  • Stores START ADDRESS, START LAT, START LNG.
  1. Filter already processed deliveries
  • Reads the sheet again, filtering for today’s date and DONE = "x".
  • These are fully geocoded deliveries ready for routing.
  1. Group deliveries by carrier
  • Groups all delivery rows by NAME CARRIER.
  1. 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.
  1. 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

  1. 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 documentId from the sheet’s URL.
  1. Google Sheets OAuth2 credentials
  • In n8n, add a Google Sheets OAuth2 API credential.
  • Use the same email that owns/edits the sheet.
  1. 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.
  1. Update workflow configuration
  • In the Google Sheets nodes (Get date delivery, Update Lat and Lng, Get addresses), replace the documentId with your own sheet ID.
  • Ensure the sheet name (Foglio1 or gid=0) matches.
  1. Set start address
  • In the Start address node (n8n-nodes-base.set), edit the START ADDRESS assignment to your warehouse/starting location.
  1. Adjust wait time
  • The Wait node is set to 10 seconds to respect Google Maps API rate limits. Adjust if needed.
  1. 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.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - When clicking ‘Execute workflow’

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 2 - Loop Over Items

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 3 - Wait

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 4 - Loop Over Items1

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 5 - Merge

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Block 6 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Get date delivery

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 8 - Update Lat and Lng

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 9 - Get Lat and Lng

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 10 - Start address

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 11 - Get Lat and Lng of Start address

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 12 - Set vars

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 13 - Get addresses

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 14 - Delivery Algorithm

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 15 - Group delivery

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 16 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 19 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 21 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 22 - Group by Carrier

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 23 - Schedule Trigger

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.3

Block 24 - Sticky Note7

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Showing the first 24 of 25 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Optimize delivery routes for carriers from Google Sheets using Google Maps
Complexity advanced
Nodes 25
Categories Project Management
Author Davide Boizza
Published 12 May 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/15673/15673.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Optimize delivery routes for carriers from Google Sheets using Google Maps do?

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

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Project Management use case.