多渠道 DHL 状态机器人
中级
这是一个Support Chatbot, AI Chatbot领域的自动化工作流,包含 15 个节点。主要使用 If, Code, Gmail, Merge, Webhook 等节点。 用于网页表单和邮件查询的自动化 DHL 包裹追踪机器人
前置要求
- •Google 账号和 Gmail API 凭证
- •HTTP Webhook 端点(n8n 会自动生成)
- •可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "sKPt2XLNb9anT2fW",
"meta": {
"instanceId": "15d6057a37b8367f33882dd60593ee5f6cc0c59310ff1dc66b626d726083b48d"
},
"name": "使用 n8N、Gmail 和 Webhook 的多渠道 DHL 状态机器人",
"tags": [],
"nodes": [
{
"id": "intro-note-1",
"name": "工作流概览",
"type": "n8n-nodes-base.stickyNote",
"position": [
-112,
80
],
"parameters": {
"width": 320,
"height": 410,
"content": "## 多渠道 DHL 状态机器人"
},
"typeVersion": 1
},
{
"id": "webhook-trigger",
"name": "Webhook 表单触发器",
"type": "n8n-nodes-base.webhook",
"position": [
304,
112
],
"webhookId": "dhl-tracking-webhook",
"parameters": {
"path": "dhl-tracking-inquiry",
"options": {},
"httpMethod": "POST",
"responseMode": "responseNode"
},
"typeVersion": 2
},
{
"id": "gmail-trigger",
"name": "Gmail 电子邮件触发器",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
304,
304
],
"parameters": {
"simple": false,
"filters": {
"sender": [],
"readStatus": "unread"
},
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "gmailCredentials",
"name": "Gmail OAuth2"
}
},
"typeVersion": 1.1
},
{
"id": "setup-note-1",
"name": "触发器设置",
"type": "n8n-nodes-base.stickyNote",
"position": [
304,
480
],
"parameters": {
"color": 3,
"width": 280,
"height": 308,
"content": "## ⚙️ 触发器配置"
},
"typeVersion": 1
},
{
"id": "merge-triggers",
"name": "合并触发器",
"type": "n8n-nodes-base.merge",
"position": [
608,
208
],
"parameters": {
"mode": "combine",
"options": {}
},
"typeVersion": 3
},
{
"id": "extract-tracking",
"name": "提取追踪号码",
"type": "n8n-nodes-base.code",
"position": [
800,
208
],
"parameters": {
"jsCode": "// Extract tracking number from different sources\nconst items = $input.all();\nconst output = [];\n\nfor (const item of items) {\n let trackingNumber = '';\n let customerEmail = '';\n let customerName = '';\n \n // Check if from webhook (form submission)\n if (item.json.body) {\n trackingNumber = item.json.body.trackingNumber || item.json.body.orderNumber || '';\n customerEmail = item.json.body.email || '';\n customerName = item.json.body.name || 'Customer';\n }\n \n // Check if from email\n if (item.json.subject || item.json.text) {\n // Extract tracking number using regex (DHL format)\n const text = item.json.text || item.json.snippet || '';\n const dhlPattern = /\\b\\d{10,}\\b/g;\n const matches = text.match(dhlPattern);\n \n if (matches && matches.length > 0) {\n trackingNumber = matches[0];\n }\n \n customerEmail = item.json.from?.value?.[0]?.address || item.json.from || '';\n customerName = item.json.from?.value?.[0]?.name || 'Customer';\n }\n \n if (trackingNumber) {\n output.push({\n json: {\n trackingNumber: trackingNumber,\n customerEmail: customerEmail,\n customerName: customerName,\n originalData: item.json\n }\n });\n }\n}\n\nreturn output;"
},
"typeVersion": 2
},
{
"id": "extraction-note",
"name": "提取逻辑",
"type": "n8n-nodes-base.stickyNote",
"position": [
688,
384
],
"parameters": {
"color": 5,
"width": 250,
"height": 236,
"content": "## 数据规范化"
},
"typeVersion": 1
},
{
"id": "dhl-api-request",
"name": "获取 DHL 追踪状态",
"type": "n8n-nodes-base.httpRequest",
"position": [
1008,
208
],
"parameters": {
"url": "https://api-eu.dhl.com/track/shipments",
"options": {
"response": {
"response": {
"responseFormat": "json"
}
}
},
"sendQuery": true,
"sendHeaders": true,
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"queryParameters": {
"parameters": [
{
"name": "trackingNumber",
"value": "={{ $json.trackingNumber }}"
}
]
},
"headerParameters": {
"parameters": [
{
"name": "DHL-API-Key",
"value": "YOUR_DHL_API_KEY"
}
]
}
},
"credentials": {
"httpHeaderAuth": {
"id": "9clRo88n4LVt91WQ",
"name": "動画生成AI_sora"
}
},
"typeVersion": 4.2
},
{
"id": "api-note",
"name": "DHL API 配置",
"type": "n8n-nodes-base.stickyNote",
"position": [
1008,
384
],
"parameters": {
"color": 4,
"width": 280,
"height": 240,
"content": "## ⚙️ DHL API 配置"
},
"typeVersion": 1
},
{
"id": "format-response",
"name": "格式化响应消息",
"type": "n8n-nodes-base.code",
"position": [
1200,
208
],
"parameters": {
"jsCode": "// Format the tracking response\nconst trackingData = $input.item.json;\nconst customerData = $node[\"Extract Tracking Number\"].json;\n\nlet statusMessage = '';\nlet trackingDetails = {};\n\ntry {\n // Parse DHL API response\n const shipment = trackingData.shipments?.[0];\n \n if (shipment) {\n const latestEvent = shipment.events?.[0];\n const status = shipment.status;\n \n trackingDetails = {\n trackingNumber: customerData.trackingNumber,\n currentStatus: status?.status || 'In Transit',\n statusDescription: status?.description || '',\n lastUpdate: latestEvent?.timestamp || new Date().toISOString(),\n location: latestEvent?.location?.address?.addressLocality || 'Unknown',\n estimatedDelivery: shipment.estimatedTimeOfDelivery || 'Not available',\n carrier: 'DHL Express'\n };\n \n statusMessage = `\nDear ${customerData.customerName},\n\nThank you for your inquiry about tracking number: ${trackingDetails.trackingNumber}\n\n📦 **Current Status:** ${trackingDetails.currentStatus}\n📍 **Last Location:** ${trackingDetails.location}\n🕒 **Last Update:** ${new Date(trackingDetails.lastUpdate).toLocaleString()}\n📅 **Estimated Delivery:** ${trackingDetails.estimatedDelivery}\n\n${trackingDetails.statusDescription}\n\nYou can track your shipment in real-time at:\nhttps://www.dhl.com/track?tracking-id=${trackingDetails.trackingNumber}\n\nIf you have any questions, please don't hesitate to contact us.\n\nBest regards,\nCustomer Service Team\n `;\n } else {\n statusMessage = `\nDear ${customerData.customerName},\n\nWe couldn't find tracking information for: ${customerData.trackingNumber}\n\nPlease verify the tracking number and try again. If the issue persists, please contact our support team.\n\nBest regards,\nCustomer Service Team\n `;\n }\n} catch (error) {\n statusMessage = `\nDear ${customerData.customerName},\n\nWe encountered an issue retrieving your tracking information. Our team has been notified and will look into this immediately.\n\nTracking Number: ${customerData.trackingNumber}\n\nPlease try again later or contact our support team for immediate assistance.\n\nBest regards,\nCustomer Service Team\n `;\n}\n\nreturn {\n json: {\n customerEmail: customerData.customerEmail,\n customerName: customerData.customerName,\n subject: `Re: DHL Tracking Update - ${customerData.trackingNumber}`,\n message: statusMessage,\n trackingDetails: trackingDetails,\n isWebhook: customerData.originalData?.body ? true : false\n }\n};"
},
"typeVersion": 2
},
{
"id": "check-source",
"name": "检查来源",
"type": "n8n-nodes-base.if",
"position": [
1408,
208
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "condition-1",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{ $json.isWebhook }}",
"rightValue": true
}
]
}
},
"typeVersion": 2
},
{
"id": "routing-note",
"name": "响应路由",
"type": "n8n-nodes-base.stickyNote",
"position": [
1344,
352
],
"parameters": {
"color": 6,
"width": 220,
"height": 232,
"content": "## 响应路由"
},
"typeVersion": 1
},
{
"id": "webhook-response",
"name": "Webhook 响应",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
1600,
112
],
"parameters": {
"options": {
"responseCode": 200,
"responseHeaders": {
"entries": [
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"respondWith": "json",
"responseBody": "={{ JSON.stringify($json.trackingDetails) }}"
},
"typeVersion": 1.1
},
{
"id": "gmail-send",
"name": "发送 Gmail 响应",
"type": "n8n-nodes-base.gmail",
"position": [
1600,
304
],
"webhookId": "3c958446-e0e3-4b3d-91c0-2dad70585160",
"parameters": {
"sendTo": "={{ $json.customerEmail }}",
"message": "={{ $json.message }}",
"options": {
"replyTo": "support@yourcompany.com"
},
"subject": "={{ $json.subject }}"
},
"credentials": {
"gmailOAuth2": {
"id": "gmailCredentials",
"name": "Gmail OAuth2"
}
},
"typeVersion": 2.1
},
{
"id": "email-config-note",
"name": "电子邮件设置",
"type": "n8n-nodes-base.stickyNote",
"position": [
1600,
464
],
"parameters": {
"color": 2,
"height": 252,
"content": "## ✉️ 电子邮件自定义"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"timezone": "America/New_York",
"errorWorkflow": "",
"executionOrder": "v1",
"saveManualExecutions": true,
"saveExecutionProgress": true,
"saveDataErrorExecution": "all",
"saveDataSuccessExecution": "all"
},
"versionId": "9066dca1-1efe-41ec-8477-457dcaadd0a8",
"connections": {
"Check Source": {
"main": [
[
{
"node": "Webhook Response",
"type": "main",
"index": 0
}
],
[
{
"node": "Send Gmail Response",
"type": "main",
"index": 0
}
]
]
},
"Merge Triggers": {
"main": [
[
{
"node": "Extract Tracking Number",
"type": "main",
"index": 0
}
]
]
},
"Gmail Email Trigger": {
"main": [
[
{
"node": "Merge Triggers",
"type": "main",
"index": 1
}
]
]
},
"Webhook Form Trigger": {
"main": [
[
{
"node": "Merge Triggers",
"type": "main",
"index": 0
}
]
]
},
"Extract Tracking Number": {
"main": [
[
{
"node": "Get DHL Tracking Status",
"type": "main",
"index": 0
}
]
]
},
"Format Response Message": {
"main": [
[
{
"node": "Check Source",
"type": "main",
"index": 0
}
]
]
},
"Get DHL Tracking Status": {
"main": [
[
{
"node": "Format Response Message",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 客服机器人, AI 聊天机器人
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
航空公司常见问题解答机器人
使用GPT-4和问题分类自动化航空公司客户支持
If
Code
Merge
+4
27 节点Oneclick AI Squad
客服机器人
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
AI医疗症状检查器与健康助手
基于GPT-4-mini的医疗症状检查与健康助手
If
Set
Code
+6
17 节点Jah coozi
客服机器人
使用GPT-4o、Brevo和NocoDB自动化销售外联和响应管理
使用GPT-4o、Brevo和NocoDB自动化销售外联和响应管理
If
Set
Code
+13
77 节点Evervise
客户培育
预约预订器 [销售版本]
集成GPT-4、ElevenLabs和Twilio的多渠道AI预约确认系统
Code
Gmail
Merge
+10
20 节点Varritech
客户培育
竞争对手内容差距分析器:自动化网站主题映射
使用Gemini AI、Apify和Google Sheets分析竞争对手内容差距
If
Set
Code
+10
30 节点Mychel Garzon
杂项
工作流信息
难度等级
中级
节点数量15
分类2
节点类型9
作者
Yusuke Yamamoto
@yusuke-yamamotoBusiness creator from Tokyo. Designing AI-driven automations that enhance marketing, reporting, and daily operations. I turn complex workflows into simple, elegant automations with n8n.
外部链接
在 n8n.io 查看 →
分享此工作流