AutomationFlowsAI & RAG › AI Agent for Transportation Orders Management with Gpt-4o and Open Route API

AI Agent for Transportation Orders Management with Gpt-4o and Open Route API

Original n8n title: 🤖🚚 AI Agent for Transportation Orders Management with Gpt-4o and Open Route API

BySamir Saci @samirsaci on n8n.io

*Tags: AI Agent, Supply Chain, Logistics, Route Planning, Transportation, GPS API*

Event trigger★★★★☆ complexityAI-powered26 nodesGmail TriggerOutput Parser StructuredAgentGoogle SheetsHTTP RequestOpenAI ChatGmail
AI & RAG Trigger: Event Nodes: 26 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #4692 — we link there as the canonical source.

This workflow follows the Agent → Gmail recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "nodes": [
    {
      "id": "f24429ab-1276-4655-a3ef-1fbbb6d80602",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        20,
        400
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {
          "downloadAttachments": false
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 1.2
    },
    {
      "id": "62ced604-4de3-4a6d-bbfe-b1c2f985117f",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        560,
        560
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"shipment_number\": \"15487-PLO\",\n  \"pickup_location\": \"Centre de Distribution Leclerc\",\n  \"pickup_address\": \"77 Rue Albert Garry, 94450 Limeil-Br\u00e9vannes\",\n  \"expected_pickup_time\": \"24-09-2024, 09:00:00\",\n  \"temperature_control\": \"Chilled\",\n  \"quantity\": \"12 pallets\",\n  \"destination_store_name\": \"E.Leclerc Store 124\",\n  \"destination_address\": \"43-45 Quai Jules Guesde, 94405 Vitry-sur-Seine\",\n  \"expected_delivery_time\": \"24-09-2024, 18:00:00\",\n  \"sender_name\":\"Jacques Chirac\",\n  \"sender_company\": \"RPR\"\n}\n\n"
      },
      "typeVersion": 1.2
    },
    {
      "id": "767ee78a-d0ff-4399-bea1-4310aff116f7",
      "name": "AI Agent Parser",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        320,
        400
      ],
      "parameters": {
        "text": "=Here is an email from a customer requesting a shipment:\n\nSubject: {{ $json.subject }}\nBody: {{ $json.text }}\n\nPlease extract all the structured logistics data based on the format provided.",
        "options": {
          "systemMessage": "=You are a logistics assistant for a transportation company. \n\nYour job is to extract all structured data from shipping request emails sent by customers (typically retail chains like E.Leclerc). These emails contain information about the sender, shipment pickup and delivery details.\n\nReturn the result as a JSON object with the following fields:\n\n{\n  \"shipment_number\": \"\",\n  \"pickup_location\": \"\",\n  \"pickup_address\": \"\",\n  \"expected_pickup_time\": \"\",\n  \"temperature_control\": \"\",\n  \"quantity\": \"\",\n  \"destination_store_name\": \"\",\n  \"destination_address\": \"\",\n  \"expected_delivery_time\": \"\",\n  \"sender_name\": \"\",\n  \"sender_company\": \"\"\n}\n\nOnly include values mentioned explicitly in the email. Do not infer or guess. If a field is missing, set its value to `null`.\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.9
    },
    {
      "id": "8a0c7eb8-322b-47c1-8547-2afe0370f3fc",
      "name": "Record Email Content",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        820,
        440
      ],
      "parameters": {
        "columns": {
          "value": {
            "pickup_address": "={{ $json.output.pickup_address }}",
            "pickup_location": "={{ $json.output.pickup_location }}",
            "shipment_number": "={{ $json.output.shipment_number }}",
            "destination_address": "={{ $json.output.destination_address }}",
            "temperature_control": "={{ $json.output.temperature_control }}",
            "expected_pickup_time": "={{ $json.output.expected_pickup_time }}",
            "destination_store_name": "={{ $json.output.destination_store_name }}",
            "expected_delivery_time": "={{ $json.output.expected_delivery_time}}"
          },
          "schema": [
            {
              "id": "shipment_number",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "shipment_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_location",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "pickup_location",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_address",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "pickup_address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_longitude",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "pickup_longitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_latitude",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "pickup_latitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "expected_pickup_time",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "expected_pickup_time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "temperature_control",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "temperature_control",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_store_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "destination_store_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_address",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "destination_address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_longitude",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "destination_longitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_latitude",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "destination_latitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "expected_delivery_time",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "expected_delivery_time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "driving_distance",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "driving_distance",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "driving_time",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "driving_time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "shipment_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Orders"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": "Transportation Orders"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.6
    },
    {
      "id": "b2c5c252-c464-4094-93c0-9c94ccd82b14",
      "name": "Collect Addresses",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        820,
        640
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.output.shipment_number }}",
              "lookupColumn": "shipment_number"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Orders"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": "Transportation Orders"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.6
    },
    {
      "id": "840698a1-2f87-43d1-a6d3-27a107d4038b",
      "name": "5 sec",
      "type": "n8n-nodes-base.wait",
      "position": [
        1700,
        540
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "82cc284e-14a4-45de-a463-511e2a70e182",
      "name": "Query Open Route API Pickup",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1040,
        540
      ],
      "parameters": {
        "url": "https://api.openrouteservice.org/geocode/search",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "api_key"
            },
            {
              "name": "text",
              "value": "={{ $json.pickup_address }}"
            },
            {
              "name": "boundary.country",
              "value": "=FR"
            },
            {
              "name": "sources",
              "value": "openstreetmap"
            },
            {
              "name": "size",
              "value": "1"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json; charset=utf-8"
            },
            {
              "name": "Accept",
              "value": "application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.2
    },
    {
      "id": "ba4f843c-f922-486d-944c-d9ea6655ccda",
      "name": "Save Pickup GPS",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1480,
        540
      ],
      "parameters": {
        "columns": {
          "value": {
            "pickup_latitude": "={{ $json.latitude }}",
            "shipment_number": "={{ $('AI Agent Parser').item.json.output.shipment_number }}",
            "pickup_longitude": "={{ $json.longitude }}"
          },
          "schema": [
            {
              "id": "shipment_number",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "shipment_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_location",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "pickup_location",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_address",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "pickup_address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_longitude",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "pickup_longitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_latitude",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "pickup_latitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "expected_pickup_time",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "expected_pickup_time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "temperature_control",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "temperature_control",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_store_name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "destination_store_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_address",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "destination_address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_longitude",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "destination_longitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_latitude",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "destination_latitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "expected_delivery_time",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "expected_delivery_time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "driving_distance",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "driving_distance",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "driving_time",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "driving_time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "shipment_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Orders"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": "Transportation Orders"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.6
    },
    {
      "id": "e87c8abb-34b4-41c2-8c4a-139248d41a20",
      "name": "GPS Pickup",
      "type": "n8n-nodes-base.set",
      "position": [
        1260,
        540
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e4c92077-f294-4e49-8276-20d1441c0c2c",
              "name": "longitude",
              "type": "string",
              "value": "={{ $json.features[0].geometry.coordinates[0] }}"
            },
            {
              "id": "899e5304-e7a1-4ce1-bf9a-f403d74934fb",
              "name": "latitude",
              "type": "string",
              "value": "={{ $json.features[0].geometry.coordinates[1] }}"
            },
            {
              "id": "5b35642b-dda4-42b8-b7bb-1275616bfb59",
              "name": "borough",
              "type": "string",
              "value": "={{ $json.features[0].properties.borough }}"
            },
            {
              "id": "aa74bd9a-f543-48e1-a69b-0e6472bda053",
              "name": "neighbourhood",
              "type": "string",
              "value": "={{ $json.features[0].properties.neighbourhood }}"
            },
            {
              "id": "7f303dc8-4e28-4d46-8e3e-9db00dbcac3a",
              "name": "localadmin",
              "type": "string",
              "value": "={{ $json.features[0].properties.localadmin }}"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "556c1a60-e086-47a2-bafe-2aa3646c7846",
      "name": "Query Open Route API Delivery",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1040,
        740
      ],
      "parameters": {
        "url": "https://api.openrouteservice.org/geocode/search",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "api_key"
            },
            {
              "name": "text",
              "value": "={{ $json.destination_address }}"
            },
            {
              "name": "boundary.country",
              "value": "=FR"
            },
            {
              "name": "sources",
              "value": "openstreetmap"
            },
            {
              "name": "size",
              "value": "1"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json; charset=utf-8"
            },
            {
              "name": "Accept",
              "value": "application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.2
    },
    {
      "id": "dd81a2cb-fe60-4e3c-95c7-08b89b111ad8",
      "name": "GPS Delivery",
      "type": "n8n-nodes-base.set",
      "position": [
        1260,
        740
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e4c92077-f294-4e49-8276-20d1441c0c2c",
              "name": "longitude",
              "type": "string",
              "value": "={{ $json.features[0].geometry.coordinates[0] }}"
            },
            {
              "id": "899e5304-e7a1-4ce1-bf9a-f403d74934fb",
              "name": "latitude",
              "type": "string",
              "value": "={{ $json.features[0].geometry.coordinates[1] }}"
            },
            {
              "id": "5b35642b-dda4-42b8-b7bb-1275616bfb59",
              "name": "borough",
              "type": "string",
              "value": "={{ $json.features[0].properties.borough }}"
            },
            {
              "id": "aa74bd9a-f543-48e1-a69b-0e6472bda053",
              "name": "neighbourhood",
              "type": "string",
              "value": "={{ $json.features[0].properties.neighbourhood }}"
            },
            {
              "id": "7f303dc8-4e28-4d46-8e3e-9db00dbcac3a",
              "name": "localadmin",
              "type": "string",
              "value": "={{ $json.features[0].properties.localadmin }}"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "652c3a8f-9e47-4386-a932-be99a94e72bd",
      "name": "Save Delivery GPS",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1480,
        740
      ],
      "parameters": {
        "columns": {
          "value": {
            "shipment_number": "={{ $('AI Agent Parser').item.json.output.shipment_number }}",
            "destination_latitude": "={{ $json.latitude }}",
            "destination_longitude": "={{ $json.longitude }}"
          },
          "schema": [
            {
              "id": "shipment_number",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "shipment_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_location",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "pickup_location",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_address",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "pickup_address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_longitude",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "pickup_longitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_latitude",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "pickup_latitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "expected_pickup_time",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "expected_pickup_time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "temperature_control",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "temperature_control",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_store_name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "destination_store_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_address",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "destination_address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_longitude",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "destination_longitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_latitude",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "destination_latitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "expected_delivery_time",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "expected_delivery_time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "driving_distance",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "driving_distance",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "driving_time",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "driving_time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "shipment_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Orders"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": "Transportation Orders"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.6
    },
    {
      "id": "0d31ad24-c3b3-42bb-b98a-ad443005341a",
      "name": "Collect Coordinates",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        820,
        940
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.output.shipment_number }}",
              "lookupColumn": "shipment_number"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Orders"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": "Transportation Orders"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.6
    },
    {
      "id": "f813ecde-ea6e-4780-9bae-2be7e171419d",
      "name": "Request Open Route API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1040,
        940
      ],
      "parameters": {
        "url": "https://api.openrouteservice.org/v2/directions/driving-hgv",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "api_key"
            },
            {
              "name": "start",
              "value": "={{ $json.pickup_longitude }}, {{ $json.pickup_latitude }}"
            },
            {
              "name": "end",
              "value": "={{ $json.destination_longitude }}, {{ $json.destination_latitude }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json; charset=utf-8"
            },
            {
              "name": "Accept",
              "value": "application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.2
    },
    {
      "id": "f9fb4321-398f-439e-832a-531245cad968",
      "name": "Save Results",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1480,
        940
      ],
      "parameters": {
        "columns": {
          "value": {
            "driving_time": "={{ $json.duration }}",
            "shipment_number": "={{ $('AI Agent Parser').item.json.output.shipment_number }}",
            "driving_distance": "={{ $json.distance }}"
          },
          "schema": [
            {
              "id": "shipment_number",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "shipment_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_location",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "pickup_location",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_address",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "pickup_address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_longitude",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "pickup_longitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "pickup_latitude",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "pickup_latitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "expected_pickup_time",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "expected_pickup_time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "temperature_control",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "temperature_control",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_store_name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "destination_store_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_address",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "destination_address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_longitude",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "destination_longitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "destination_latitude",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "destination_latitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "expected_delivery_time",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "expected_delivery_time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "driving_distance",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "driving_distance",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "driving_time",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "driving_time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "shipment_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Orders"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "17wbroY0w6xmw8AT-p2c_n1WbHzmfesz6d1DJbp39fn8",
          "cachedResultUrl": "",
          "cachedResultName": "Transportation Orders"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.6
    },
    {
      "id": "ac878430-fe68-42ee-9b0b-20ad9a245d9b",
      "name": "Collect Shipment Information",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        800,
        1520
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.output.shipment_number }}",
              "lookupColumn": "shipment_number"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Orders"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": "Transportation Orders"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.6
    },
    {
      "id": "21631974-c8a7-4b0c-a19b-3edcf2682200",
      "name": "Driving Time & Distance",
      "type": "n8n-nodes-base.set",
      "position": [
        1260,
        940
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "4d0acd1a-c049-4353-9fb7-8eb08c138b9c",
              "name": "distance",
              "type": "string",
              "value": "={{ ($json.features[0].properties.segments[0].distance.round()/1000).toFixed(2) }}"
            },
            {
              "id": "2a6ff46a-f620-4dad-a60a-018b8add76d5",
              "name": "duration",
              "type": "string",
              "value": "={{ ($json.features[0].properties.segments[0].duration/60).toFixed(2) }}"
            },
            {
              "id": "de20932f-4eb5-4372-ad6d-64679df104cb",
              "name": "n_steps",
              "type": "number",
              "value": "={{ $json.features[0].properties.segments[0].steps.length }}"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "aad7e5f3-5eae-4be1-beb5-e57f7723086f",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        940,
        1660
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "a73dfa1c-4f4e-4cab-950d-91021fc28c5d",
      "name": "AI Agent Reply",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1000,
        1520
      ],
      "parameters": {
        "text": "=Here is the output:\n\n- Shipment Number: {{ $json.shipment_number }}\n- Pickup Location: {{ $json.pickup_location }}\n- Pickup Address: {{ $json.pickup_address }}  \n- Expected Pickup Time: {{ $json.expected_pickup_time }}  \n- Temperature Control: {{ $json.temperature_control }}  \n- Destination: {{ $json.destination_store_name }} \n- Destination Address: {{ $json.destination_address }}\n- Expected Delivery Time: {{ $json.expected_delivery_time }} \n- Driving Distance: {{ $json.driving_distance }} km\n- Estimated Transit Time: {{ $json.driving_time }} min\n- Contact Name: {{ $('AI Agent Parser').item.json.output.sender_name }}\n- Contact Company: {{ $('AI Agent Parser').item.json.output.sender_company }}\n",
        "options": {
          "systemMessage": "=You are a logistics assistant working for a transportation company. Your job is to write polite and professional response confirming shipment planification to retail customers.\n\nYour tone should be clear, efficient, and customer-friendly. Keep it concise and formal.\n\nThe confirmation must repeat the key shipment details to avoid confusion and should reassure the customer that the transport has been scheduled.\n\nDo not invent details \u2014 only use the provided data. The email must be in **English**.\n\n\u26a0\ufe0f Always format the result in **HTML**, not plain text or Markdown. Use proper HTML tags like `<p>`, `<strong>`, `<br>`, and `<ul><li>` where needed.\n\nYou do not need to add a subject, just the body.\n\nAbout you\n[Name]: LogiGreen Bot\n[Position]: Transportation Planner\n[Company]: LogiGreen Transportation\n[Contact]: logigreenbot@gmail.com\n\n"
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "4d83c51c-b124-4732-9757-6b5490002425",
      "name": "Reply",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1340,
        1520
      ],
      "parameters": {
        "message": "={{ $json.output }}",
        "options": {},
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "operation": "reply"
      },
      "notesInFlow": true,
      "typeVersion": 2.1
    },
    {
      "id": "958e7446-0078-4823-a696-eca00fa6c3fb",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        780,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 1040,
        "height": 1100,
        "content": "### 3. Record Shipment Request Information and fetch distance and driving time using Open Route API\nThis starts by recording all the information parsed by the AI node. Then, we use the **Open Route API** to complete with **geocoding data** *(GPS Coordinates)* that will be used to fetch **driving distance and time**.\n\n#### How to setup?\n- **Setup API Credentials**\n  1. Get your free API key: [Open Route API Documentation](https://openrouteservice.org/dev/#/api-docs)\n  2. Fill the API key in the HTTP request node\n  3. Select the driving mode (**driving-car**: individual truck) or (**driving-hgv**: commercial truck)\n- **Load records in the Google Sheet Node**:\n   1. Add your Google Sheet API credentials to access the Google Sheet file\n   2. Select the file using the list, an URL or an ID\n   3. Select the sheet in which you want to record your working sessions\n   4. Map the fields: **shipment_number**, **pickup_location**, **pickup_address**, **pickup_longitude**, **pickup_latitude**, **expected_pickup_time**,\t**temperature_control**, **destination_store_name**, **destination_address**, **destination_longitude**, **destination_latitude**, **expected_delivery_time**, **driving_distance**, **driving_time**\t\t\t\t\t\t\t\t\t\t\t\t\t\n  [Learn more about the Google Sheet Node](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.googlesheets)\n\nLongitudes, latitudes, distance and time will be fetched from the **Open Route API**.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "1ef6e4fd-67a2-4d07-a6a8-294456fc3fad",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 180,
        "height": 700,
        "content": "### 1. Workflow Trigger with Gmail Trigger\nThe workflow is triggered by a new email received in your Gmail mailbox dedicated to process **shipment request**.\n\n#### How to setup?\n- **Gmail Trigger Node:** set up your Gmail API credentials\n[Learn more about the Gmail Trigger Node](https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.gmailtrigger)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "c470fc5f-b74b-4b3f-b9bd-6e52220f9159",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 700,
        "content": "### 2. AI Agent to parse shipment information from email\nThis node will analyze the content of the email to extract information about the **sender** *(name, company)* and the **shipment** *(departure, arrival, timing and locations)*.\n\n#### How to setup?\n- **AI Agent with the Chat Model**:\n   1. Add a **chat model** with the required credentials *(Example: Open AI 4o-mini)*\n   2. Adapt the system prompt to the format of emails you expect to receive *(type of information included)*\n  [Learn more about the AI Agent Node](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "80ed9218-8c59-4b1b-b3a6-f97f2ece11c8",
      "name": "OpenAI Chat Model2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        240,
        560
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "30592283-3d1e-4f41-b18f-55e4dd87457e",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        780,
        1120
      ],
      "parameters": {
        "color": 7,
        "width": 680,
        "height": 720,
        "content": "### 4. Reply with a confirmation of shipment allocation\nWe first collect all the information from the **Google Sheets** that will be used by the AI Agent to generate a reply by email.\n#### How to setup?\n- **Load records in the Google Sheet Node**:\n   1. Add your Google Sheet API credentials to access the Google Sheet file\n   2. Select the file using the list, an URL or an ID\n   3. Select the sheet in which you want to record your working sessions\t\t\t\t\t\t\t\t\t\t\t\n  [Learn more about the Google Sheet Node](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.googlesheets)\n- **AI Agent with the Chat Model**:\n   1. Add a **chat model** with the required credentials *(Example: Open AI 4o-mini)*\n   2. Adapt the system prompt with your company information **(name, contact, position)**\n  [Learn more about the AI Agent Node](https://docs.n8n.io/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent)\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7cce6421-6771-4cdf-a8aa-6454c6a4e27f",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        720
      ],
      "parameters": {
        "width": 580,
        "height": 380,
        "content": "### [Check the Tutorial](https://youtu.be/0InkUBOUMQQ)\n![Thumbnail](https://www.samirsaci.com/content/images/2025/06/temp.png)"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "GPS Pickup": {
      "main": [
        [
          {
            "node": "Save Pickup GPS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPS Delivery": {
      "main": [
        [
          {
            "node": "Save Delivery GPS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "AI Agent Parser",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent Reply": {
      "main": [
        [
          {
            "node": "Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent Parser": {
      "main": [
        [
          {
            "node": "Collect Coordinates",
            "type": "main",
            "index": 0
          },
          {
            "node": "Record Email Content",
            "type": "main",
            "index": 0
          },
          {
            "node": "Collect Addresses",
            "type": "main",
            "index": 0
          },
          {
            "node": "Collect Shipment Information",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Pickup GPS": {
      "main": [
        [
          {
            "node": "5 sec",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect Addresses": {
      "main": [
        [
          {
            "node": "Query Open Route API Pickup",
            "type": "main",
            "index": 0
          },
          {
            "node": "Query Open Route API Delivery",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent Reply",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Collect Coordinates": {
      "main": [
        [
          {
            "node": "Request Open Route API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Request Open Route API": {
      "main": [
        [
          {
            "node": "Driving Time & Distance",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Driving Time & Distance": {
      "main": [
        [
          {
            "node": "Save Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent Parser",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Query Open Route API Pickup": {
      "main": [
        [
          {
            "node": "GPS Pickup",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect Shipment Information": {
      "main": [
        [
          {
            "node": "AI Agent Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Query Open Route API Delivery": {
      "main": [
        [
          {
            "node": "GPS Delivery",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

*Tags: AI Agent, Supply Chain, Logistics, Route Planning, Transportation, GPS API*

Source: https://n8n.io/workflows/4692/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Want to skip the manual work and instantly generate SWOT analyses for your business plans, investor decks, or strategy docs? 🚀 This workflow lets you automate the entire SWOT (Strengths, Weaknesses, O

Google Sheets, Agent, Output Parser Structured +4
AI & RAG

This n8n workflow automates sales processes using AI agents integrated with Airtable as a CRM and Gmail for email handling. It consists of two main workflows: one for handling Airtable status changes

Airtable Trigger, Agent, OpenAI Chat +9
AI & RAG

The workflow runs every hour with a randomized delay of 5–20 minutes to help distribute load. It records the exact date and time a lead is emailed so you can track outreach. Follow-ups are automatical

Google Sheets, Agent, OpenAI Chat +5
AI & RAG

mails2notion V2. Uses lmChatOpenAi, toolCalculator, outputParserStructured, gmail. Event-driven trigger; 38 nodes.

OpenAI Chat, Tool Calculator, Output Parser Structured +5
AI & RAG

This workflow automatically creates Tasks from forwarded Emails, similar to Asana, but better. Emails are processed by AI and converted to rather actionable task.

OpenAI Chat, Tool Calculator, Output Parser Structured +5