8
n8n 中文网amn8n.com

带有快递API更新和客户提醒的每日货运跟踪器

中级

这是一个Miscellaneous领域的自动化工作流,包含 13 个节点。主要使用 If, Code, Cron, Filter, EmailSend 等节点。 使用DHL/Delhivery API跟踪货运,并通过WhatsApp/邮件向客户发送Google Sheets更新

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "JORMNG6XHP1Akgbo",
  "meta": {
    "instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
    "templateCredsSetupCompleted": true
  },
  "name": "带有快递 API 更新和客户提醒的每日货运跟踪器",
  "tags": [],
  "nodes": [
    {
      "id": "b2117104-5779-441c-937f-bb09ee7b07f9",
      "name": "每日触发器",
      "type": "n8n-nodes-base.cron",
      "position": [
        -660,
        200
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9b0abc15-5ad5-4585-b755-c30b7193dcff",
      "name": "获取货运列表",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -440,
        200
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "=iuhgt678io"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "jko9876trde456yhn"
        },
        "authentication": "serviceAccount",
        "combineFilters": "AND"
      },
      "credentials": {
        "googleApi": {
          "id": "ScSS2KxGQULuPtdy",
          "name": "Google Sheets- test"
        }
      },
      "typeVersion": 4
    },
    {
      "id": "b4e26387-7f4e-4f5b-846e-36ea97d5cec6",
      "name": "筛选活跃货运",
      "type": "n8n-nodes-base.filter",
      "position": [
        -220,
        200
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "condition-1",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "delivered"
            },
            {
              "id": "condition-2",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.tracking_number }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "a0d9cf87-83c1-4b3f-b844-8913d7b55ef9",
      "name": "通过 Delhivery 跟踪",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        220,
        100
      ],
      "parameters": {
        "url": "https://track.delhivery.com/api/v1/packages/json/",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "waybill",
              "value": "={{ $json.tracking_number }}"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "KCqBydsOZHvzNKAI",
          "name": "Header Auth account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f1853f77-3060-4150-8a35-cefdc20c7ae1",
      "name": "通过 DHL 跟踪",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        220,
        300
      ],
      "parameters": {
        "url": "https://api-eu.dhl.com/track/shipments",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "trackingNumber",
              "value": "={{ $json.tracking_number }}"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "KCqBydsOZHvzNKAI",
          "name": "Header Auth account"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "6b395480-8d71-4492-8b3e-986992b1db3d",
      "name": "按快递公司路由",
      "type": "n8n-nodes-base.if",
      "position": [
        0,
        200
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "condition-1",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.courier }}",
              "rightValue": "delhivery"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "62185200-0431-449d-9b1b-6b96d63c2893",
      "name": "解析跟踪数据",
      "type": "n8n-nodes-base.code",
      "position": [
        440,
        200
      ],
      "parameters": {
        "jsCode": "// Parse tracking response and extract relevant information\nconst items = [];\n\nfor (const item of $input.all()) {\n  const trackingData = item.json;\n  \n  let status = 'unknown';\n  let location = '';\n  let lastUpdated = '';\n  let estimatedDelivery = '';\n  \n  // Parse Delhivery response\n  if (trackingData.ShipmentData && trackingData.ShipmentData.length > 0) {\n    const shipment = trackingData.ShipmentData[0];\n    status = shipment.Status?.Status || 'unknown';\n    location = shipment.Status?.StatusLocation || '';\n    lastUpdated = shipment.Status?.StatusDateTime || '';\n    estimatedDelivery = shipment.ExpectedDeliveryDate || '';\n  }\n  \n  // Parse DHL response\n  if (trackingData.shipments && trackingData.shipments.length > 0) {\n    const shipment = trackingData.shipments[0];\n    if (shipment.status) {\n      status = shipment.status.statusCode || 'unknown';\n      location = shipment.status.location || '';\n      lastUpdated = shipment.status.timestamp || '';\n    }\n  }\n  \n  // Normalize status values\n  const normalizedStatus = {\n    'Delivered': 'delivered',\n    'delivered': 'delivered',\n    'In Transit': 'in_transit',\n    'in_transit': 'in_transit',\n    'Out for Delivery': 'out_for_delivery',\n    'Picked up': 'picked_up',\n    'Exception': 'exception'\n  }[status] || 'in_transit';\n  \n  items.push({\n    json: {\n      tracking_number: item.json.tracking_number || '',\n      customer_email: item.json.customer_email || '',\n      customer_phone: item.json.customer_phone || '',\n      order_id: item.json.order_id || '',\n      current_status: normalizedStatus,\n      previous_status: item.json.status || '',\n      location: location,\n      last_updated: lastUpdated,\n      estimated_delivery: estimatedDelivery,\n      status_changed: (item.json.status !== normalizedStatus)\n    }\n  });\n}\n\nreturn items;"
      },
      "typeVersion": 2
    },
    {
      "id": "3a97de9e-ec0e-4628-adab-2758162bfc6c",
      "name": "检查状态变更",
      "type": "n8n-nodes-base.filter",
      "position": [
        660,
        200
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "condition-1",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status_changed }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "2e53cd9a-9e16-4c9f-87a5-f06ac949596d",
      "name": "更新 Google 表格",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        880,
        0
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "=09iuok"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "0iuhgy678o"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "ScSS2KxGQULuPtdy",
          "name": "Google Sheets- test"
        }
      },
      "typeVersion": 4
    },
    {
      "id": "dab15a3e-4632-43fa-a5a3-2b39bab593cb",
      "name": "发送 WhatsApp 更新",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        880,
        200
      ],
      "parameters": {
        "url": "https://api.whatsapp.com/send",
        "options": {},
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "phone",
              "value": "={{ $json.customer_phone }}"
            },
            {
              "name": "text",
              "value": "🚚 Shipment Update for Order #{{ $json.order_id }}\\n\\nTracking: {{ $json.tracking_number }}\\nStatus: {{ $json.current_status }}\\nLocation: {{ $json.location }}\\nLast Updated: {{ $json.last_updated }}\\n\\n{{ $json.estimated_delivery ? 'Estimated Delivery: ' + $json.estimated_delivery : '' }}\\n\\nThank you for choosing us! 📦"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a23a973c-d76b-4a51-a485-ed65da3da1aa",
      "name": "发送电子邮件更新",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        880,
        400
      ],
      "webhookId": "72e0400b-c0c8-4883-9a64-32bf9039a5ff",
      "parameters": {
        "options": {},
        "subject": "Shipment Update - Order #{{ $json.order_id }}",
        "toEmail": "={{ $json.customer_email }}",
        "fromEmail": "noreply@yourcompany.com"
      },
      "credentials": {
        "smtp": {
          "id": "G1kyF8cSWTZ4vouN",
          "name": "SMTP -test"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "9acd8aba-d127-4eec-b276-36dce8ef582c",
      "name": "执行摘要",
      "type": "n8n-nodes-base.code",
      "position": [
        1100,
        200
      ],
      "parameters": {
        "jsCode": "// Log workflow execution summary\nconst processedItems = $input.all().length;\nconst updatedItems = $input.all().filter(item => item.json.status_changed).length;\n\nconsole.log(`Shipment Tracking Summary:`);\nconsole.log(`- Total shipments processed: ${processedItems}`);\nconsole.log(`- Shipments with status updates: ${updatedItems}`);\nconsole.log(`- Execution completed at: ${new Date().toISOString()}`);\n\nreturn [{\n  json: {\n    summary: {\n      processed: processedItems,\n      updated: updatedItems,\n      timestamp: new Date().toISOString()\n    }\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "e959e416-7e2e-4848-a9df-deda76a88204",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -580,
        -420
      ],
      "parameters": {
        "color": 4,
        "width": 660,
        "height": 320,
        "content": "## 工作原理"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d01d33c3-9470-4b29-a8bf-1a0509b18d28",
  "connections": {
    "Daily Trigger": {
      "main": [
        [
          {
            "node": "Get Shipments List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Track via DHL": {
      "main": [
        [
          {
            "node": "Parse Tracking Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Courier": {
      "main": [
        [
          {
            "node": "Track via Delhivery",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Track via DHL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email Update": {
      "main": [
        [
          {
            "node": "Execution Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Shipments List": {
      "main": [
        [
          {
            "node": "Filter Active Shipments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Status Change": {
      "main": [
        [
          {
            "node": "Update Google Sheet",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send WhatsApp Update",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Email Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Tracking Data": {
      "main": [
        [
          {
            "node": "Check Status Change",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Track via Delhivery": {
      "main": [
        [
          {
            "node": "Parse Tracking Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Google Sheet": {
      "main": [
        [
          {
            "node": "Execution Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send WhatsApp Update": {
      "main": [
        [
          {
            "node": "Execution Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Active Shipments": {
      "main": [
        [
          {
            "node": "Route by Courier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 杂项

需要付费吗?

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

工作流信息
难度等级
中级
节点数量13
分类1
节点类型8
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Oneclick AI Squad

Oneclick AI Squad

@oneclick-ai

The AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.

外部链接
在 n8n.io 查看

分享此工作流