8
n8n 中文网amn8n.com

🤖🚚 基于GPT-4o和Open Route API的运输订单管理AI代理

高级

这是一个AI, IT Ops领域的自动化工作流,包含 26 个节点。主要使用 Set, Wait, Gmail, HttpRequest, GmailTrigger 等节点,结合人工智能技术实现智能自动化。 🤖🚚 基于GPT-4o和Open Route API的运输订单管理AI代理

前置要求
  • Google 账号和 Gmail API 凭证
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": ""
  },
  "nodes": [
    {
      "id": "f24429ab-1276-4655-a3ef-1fbbb6d80602",
      "name": "Gmail 触发器",
      "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": "结构化输出解析器",
      "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évannes\",\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代理解析器",
      "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": "记录邮件内容",
      "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": "收集地址",
      "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": {
          "id": "ePnaAS4PG1sN2E50",
          "name": "Google Sheets LogiGreenBot"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.6
    },
    {
      "id": "840698a1-2f87-43d1-a6d3-27a107d4038b",
      "name": "5秒",
      "type": "n8n-nodes-base.wait",
      "position": [
        1700,
        540
      ],
      "webhookId": "6ecebf96-14ed-4c7b-b467-eb48c143408e",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "82cc284e-14a4-45de-a463-511e2a70e182",
      "name": "查询Open Route API取货点",
      "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": "保存取货点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取货点",
      "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": "查询Open Route API配送点",
      "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配送点",
      "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": "保存配送点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": "收集坐标",
      "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": {
          "id": "ePnaAS4PG1sN2E50",
          "name": "Google Sheets LogiGreenBot"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.6
    },
    {
      "id": "f813ecde-ea6e-4780-9bae-2be7e171419d",
      "name": "请求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": "保存结果",
      "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": {
          "id": "ePnaAS4PG1sN2E50",
          "name": "Google Sheets LogiGreenBot"
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.6
    },
    {
      "id": "ac878430-fe68-42ee-9b0b-20ad9a245d9b",
      "name": "收集货运信息",
      "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": "行驶时间与距离",
      "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 聊天模型",
      "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代理回复",
      "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 — only use the provided data. The email must be in **English**.\n\n⚠️ 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": "回复",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1340,
        1520
      ],
      "webhookId": "2b6b8447-1f25-4ceb-8c5f-e14f6b6f425a",
      "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": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        780,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 1040,
        "height": 1100,
        "content": "### 3. 记录货运请求信息并使用Open Route API获取距离和行驶时间"
      },
      "typeVersion": 1
    },
    {
      "id": "1ef6e4fd-67a2-4d07-a6a8-294456fc3fad",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 180,
        "height": 700,
        "content": "### 1. 使用Gmail触发器的工作流触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "c470fc5f-b74b-4b3f-b9bd-6e52220f9159",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 700,
        "content": "### 2. AI代理从邮件解析货运信息"
      },
      "typeVersion": 1
    },
    {
      "id": "80ed9218-8c59-4b1b-b3a6-f97f2ece11c8",
      "name": "OpenAI 聊天模型2",
      "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": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        780,
        1120
      ],
      "parameters": {
        "color": 7,
        "width": 680,
        "height": 720,
        "content": "### 4. 回复货运分配确认"
      },
      "typeVersion": 1
    },
    {
      "id": "7cce6421-6771-4cdf-a8aa-6454c6a4e27f",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        720
      ],
      "parameters": {
        "width": 580,
        "height": 380,
        "content": "### [查看教程](https://youtu.be/0InkUBOUMQQ)"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "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
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 人工智能, IT 运维

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量26
分类2
节点类型10
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
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

外部链接
在 n8n.io 查看

分享此工作流