🚚 Estimation du temps de conduite et de la distance en utilisant l'API Open Route

Intermédiaire

Ceci est unAI, IT Opsworkflow d'automatisation du domainecontenant 9 nœuds.Utilise principalement des nœuds comme Set, Wait, HttpRequest, GoogleSheets, ManualTrigger, combinant la technologie d'intelligence artificielle pour une automatisation intelligente. 🚚 Estimation du temps et de la distance de conduite logistique avec l'API Open Route

Prérequis
  • Peut nécessiter les informations d'identification d'authentification de l'API cible
  • Informations d'identification Google Sheets API
Aperçu du workflow
Visualisation des connexions entre les nœuds, avec support du zoom et du déplacement
Exporter le workflow
Copiez la configuration JSON suivante dans n8n pour importer et utiliser ce workflow
{
  "id": "xcH7MXYzo44y7L7X",
  "meta": {
    "instanceId": "",
    "templateCredsSetupCompleted": true
  },
  "name": "🚚 Estimate Driving Time and Distance with Open Route API",
  "tags": [],
  "nodes": [
    {
      "id": "ce1b3c7f-315a-4714-b616-ecdd9804ee78",
      "name": "Boucle sur les éléments",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        420,
        -20
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "5a36857f-6b42-4a5b-af68-d2cfaf00ddd3",
      "name": "Extraire les résultats",
      "type": "n8n-nodes-base.set",
      "position": [
        980,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "4d0acd1a-c049-4353-9fb7-8eb08c138b9c",
              "name": "distance",
              "type": "string",
              "value": "={{ $json.features[0].properties.segments[0].distance }}"
            },
            {
              "id": "2a6ff46a-f620-4dad-a60a-018b8add76d5",
              "name": "duration",
              "type": "string",
              "value": "={{ $json.features[0].properties.segments[0].duration }}"
            },
            {
              "id": "de20932f-4eb5-4372-ad6d-64679df104cb",
              "name": "n_steps",
              "type": "number",
              "value": "={{ $json.features[0].properties.segments[0].steps.length }}"
            },
            {
              "id": "540df5ea-cf63-47cc-8d63-3d6fcac825af",
              "name": "",
              "type": "string",
              "value": ""
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "39a779dd-455b-4502-b17f-8c86d6e47e45",
      "name": "Requête Open Route API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        740,
        0
      ],
      "parameters": {
        "url": "https://api.openrouteservice.org/v2/directions/driving-hgv",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "api_key",
              "value": ""
            },
            {
              "name": "start",
              "value": "={{ $json.longitude_departure }}, {{ $json.latitude_departure }}"
            },
            {
              "name": "end",
              "value": "={{ $json.longitude_destination }}, {{ $json.latitude_destination }}"
            }
          ]
        },
        "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": "578e34fd-8804-454b-b6be-25d534eb4283",
      "name": "Collecter les itinéraires",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        60,
        -20
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Distance"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1NLNviRoVMEj2z78KiueruB5sd2CnvAb80DS7J2melVs",
          "cachedResultUrl": "",
          "cachedResultName": "Open Route Service"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "89320458-8aa8-4faf-8009-0f65899762e1",
      "name": "Sauvegarder les résultats",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1200,
        0
      ],
      "parameters": {
        "columns": {
          "value": {
            "id": "={{ $('Loop Over Items').item.json.id }}",
            "n_steps": "={{ $json.n_steps }}",
            "distance": "={{ $json.distance }}",
            "duration": "={{ $json.duration }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "city_departure",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "city_departure",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "longitude_departure",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "longitude_departure",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "latitude_departure",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "latitude_departure",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "city_destination",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "city_destination",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "longitude_destination",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "longitude_destination",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "latitude_destination",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "latitude_destination",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "distance",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "distance",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "duration",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "duration",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "n_steps",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "n_steps",
              "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": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "",
          "name": ""
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.6
    },
    {
      "id": "7f83e93e-a759-4724-8978-5de0f565b17d",
      "name": "Note adhésive 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -440
      ],
      "parameters": {
        "color": 7,
        "width": 540,
        "height": 640,
        "content": "### 1. Trigger the workflow\nThis starts by collecting all the routes (Departure, Destination) that need distance and driving time by **truck**.\n\n#### How to setup?\n\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: **city_departure**, **longitude_departure** , **latitude_departure**, **city_destination**, **longitude_destination**, **latitude_destination**, **distance**, **duration**, **n_steps**\n  [Learn more about the Google Sheet Node](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.googlesheets)\n\nThe last three fields must be left empty as they will be filled with the API outputs.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0dd453dd-2a7e-4039-a15d-2936a8ad4d44",
      "name": "Lors du clic sur 'Tester le workflow'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -160,
        -20
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "45b1dc8a-ed85-424f-89f6-656861b118b6",
      "name": "Note adhésive",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        340,
        -440
      ],
      "parameters": {
        "color": 7,
        "width": 1240,
        "height": 640,
        "content": "### 2. Loop to collect all driving distances and time \nThis starts by collecting all the routes (Departure, Destination) that need distance and driving time by **truck**.\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: **city_departure**, **longitude_departure**, **latitude_departure**, **city_destination**, **longitude_destination**, **latitude_destination**, **distance**, **duration**, **n_steps**\n  [Learn more about the Google Sheet Node](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.googlesheets)\n\nThe last three fields must be left empty as they will be filled with the API outputs.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "11232056-fc3b-422c-b569-8a4fc9250633",
      "name": "5 sec",
      "type": "n8n-nodes-base.wait",
      "position": [
        1420,
        0
      ],
      "webhookId": "1c5df276-94b5-42b8-9748-634e389cadcf",
      "parameters": {},
      "typeVersion": 1.1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "91a86656-7afe-4e84-921d-3361c4114016",
  "connections": {
    "11232056-fc3b-422c-b569-8a4fc9250633": {
      "main": [
        [
          {
            "node": "ce1b3c7f-315a-4714-b616-ecdd9804ee78",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "89320458-8aa8-4faf-8009-0f65899762e1": {
      "main": [
        [
          {
            "node": "11232056-fc3b-422c-b569-8a4fc9250633",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "578e34fd-8804-454b-b6be-25d534eb4283": {
      "main": [
        [
          {
            "node": "ce1b3c7f-315a-4714-b616-ecdd9804ee78",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5a36857f-6b42-4a5b-af68-d2cfaf00ddd3": {
      "main": [
        [
          {
            "node": "89320458-8aa8-4faf-8009-0f65899762e1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ce1b3c7f-315a-4714-b616-ecdd9804ee78": {
      "main": [
        [],
        [
          {
            "node": "39a779dd-455b-4502-b17f-8c86d6e47e45",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "39a779dd-455b-4502-b17f-8c86d6e47e45": {
      "main": [
        [
          {
            "node": "5a36857f-6b42-4a5b-af68-d2cfaf00ddd3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0dd453dd-2a7e-4039-a15d-2936a8ad4d44": {
      "main": [
        [
          {
            "node": "578e34fd-8804-454b-b6be-25d534eb4283",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Foire aux questions

Comment utiliser ce workflow ?

Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.

Dans quelles scénarios ce workflow est-il adapté ?

Intermédiaire - Intelligence Artificielle, Opérations IT

Est-ce payant ?

Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.

Informations sur le workflow
Niveau de difficulté
Intermédiaire
Nombre de nœuds9
Catégorie2
Types de nœuds7
Description de la difficulté

Adapté aux utilisateurs expérimentés, avec des workflows de complexité moyenne contenant 6-15 nœuds

Auteur
Samir Saci

Samir Saci

@samirsaci

Automation, AI and Analytics for Supply Chain & Business Optimization Helping businesses streamline operations using n8n, AI agents, and data science to enhance efficiency and sustainability. Linkedin: www.linkedin.com/in/samir-saci

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34