Multi-Channel-DHL-Status-Bot

Fortgeschritten

Dies ist ein Support Chatbot, AI Chatbot-Bereich Automatisierungsworkflow mit 15 Nodes. Hauptsächlich werden If, Code, Gmail, Merge, Webhook und andere Nodes verwendet. Automatisierter DHL-Paketverfolgungsbot für Webformulare und E-Mail-Anfragen

Voraussetzungen
  • Google-Konto + Gmail API-Anmeldedaten
  • HTTP Webhook-Endpunkt (wird von n8n automatisch generiert)
  • Möglicherweise sind Ziel-API-Anmeldedaten erforderlich
Workflow-Vorschau
Visualisierung der Node-Verbindungen, mit Zoom und Pan
Workflow exportieren
Kopieren Sie die folgende JSON-Konfiguration und importieren Sie sie in n8n
{
  "id": "sKPt2XLNb9anT2fW",
  "meta": {
    "instanceId": "15d6057a37b8367f33882dd60593ee5f6cc0c59310ff1dc66b626d726083b48d"
  },
  "name": "Multi-Channel DHL Status Bot with n8n, Gmail, and Webhooks",
  "tags": [],
  "nodes": [
    {
      "id": "intro-note-1",
      "name": "Workflow-Übersicht",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        80
      ],
      "parameters": {
        "width": 320,
        "height": 410,
        "content": "## Multi-Channel DHL Status Bot\n\nThis workflow automatically answers customer inquiries about DHL shipment status from two different channels: web forms and email.\n\n**Channels Handled:**\n- **Webhooks:** For 'Track My Order' forms on your website.\n- **Gmail:** For direct email inquiries.\n\n**Process Flow:**\n1. Receives a tracking number from either source.\n2. Fetches the latest status from the DHL API.\n3. Sends a formatted response back to the original channel."
      },
      "typeVersion": 1
    },
    {
      "id": "webhook-trigger",
      "name": "Webhook Formular-Trigger",
      "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 E-Mail-Trigger",
      "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": "Trigger-Einrichtung",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        304,
        480
      ],
      "parameters": {
        "color": 3,
        "width": 280,
        "height": 308,
        "content": "## ⚙️ Trigger Configuration\n\n**1. Gmail Trigger:**\n- Select the 'Gmail Email Trigger' node.\n- Connect your Gmail OAuth2 credentials.\n- **Action:** This allows the workflow to monitor an inbox for new tracking inquiries.\n\n**2. Webhook Trigger:**\n- Copy the Production URL from the 'Webhook Form Trigger' node.\n- **Action:** Paste this URL into your website's form settings (e.g., WordPress, Webflow, custom HTML form)."
      },
      "typeVersion": 1
    },
    {
      "id": "merge-triggers",
      "name": "Trigger zusammenführen",
      "type": "n8n-nodes-base.merge",
      "position": [
        608,
        208
      ],
      "parameters": {
        "mode": "combine",
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "extract-tracking",
      "name": "Sendungsnummer extrahieren",
      "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": "Extraktionslogik",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        384
      ],
      "parameters": {
        "color": 5,
        "width": 250,
        "height": 236,
        "content": "## Data Normalization\n\nThis Code node unifies data from both triggers.\n\n**It extracts:**\n- Tracking Number (from form body or email text)\n- Customer Email\n- Customer Name\n\nThis ensures the rest of the workflow can process the data in a consistent format, regardless of the source."
      },
      "typeVersion": 1
    },
    {
      "id": "dhl-api-request",
      "name": "DHL-Sendungsstatus abrufen",
      "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 Konfiguration",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1008,
        384
      ],
      "parameters": {
        "color": 4,
        "width": 280,
        "height": 240,
        "content": "## ⚙️ DHL API Configuration\n\n**Action Required:** You must add your DHL API key to proceed.\n\n1. **Get API Key:** Register and get a key from the [DHL Developer Portal](https://developer.dhl.com/).\n2. **Add Key to Node:**\n   - Select the 'Get DHL Tracking Status' node.\n   - Go to `Headers` > `Header Parameters`.\n   - Replace `YOUR_DHL_API_KEY` with your actual key."
      },
      "typeVersion": 1
    },
    {
      "id": "format-response",
      "name": "Antwortnachricht formatieren",
      "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": "Quelle prüfen",
      "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": "Antwort-Routing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1344,
        352
      ],
      "parameters": {
        "color": 6,
        "width": 220,
        "height": 232,
        "content": "## Response Routing\n\nThis IF node intelligently routes the response based on the original inquiry source.\n\n- **If `isWebhook` is true:** The workflow sends a JSON response back to the web form.\n- **If `isWebhook` is false:** The workflow sends a formatted reply via Gmail."
      },
      "typeVersion": 1
    },
    {
      "id": "webhook-response",
      "name": "Webhook Antwort",
      "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 Antwort senden",
      "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": "E-Mail-Einrichtung",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        464
      ],
      "parameters": {
        "color": 2,
        "height": 252,
        "content": "## ✉️ Email Customization\n\nCustomize the automated email reply.\n\n**Suggestions:**\n- **Set `Reply-To` in 'Send Gmail Response' node:** Add a support address like `support@yourcompany.com`.\n- **Refine Message:** Edit the email body in the \"Format Response Message\" node to add your company signature or branding."
      },
      "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": "gmail-send",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "merge-triggers": {
      "main": [
        [
          {
            "node": "extract-tracking",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "gmail-trigger": {
      "main": [
        [
          {
            "node": "merge-triggers",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "webhook-trigger": {
      "main": [
        [
          {
            "node": "merge-triggers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "extract-tracking": {
      "main": [
        [
          {
            "node": "dhl-api-request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "format-response": {
      "main": [
        [
          {
            "node": "check-source",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "dhl-api-request": {
      "main": [
        [
          {
            "node": "format-response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Häufig gestellte Fragen

Wie verwende ich diesen Workflow?

Kopieren Sie den obigen JSON-Code, erstellen Sie einen neuen Workflow in Ihrer n8n-Instanz und wählen Sie "Aus JSON importieren". Fügen Sie die Konfiguration ein und passen Sie die Anmeldedaten nach Bedarf an.

Für welche Szenarien ist dieser Workflow geeignet?

Fortgeschritten - Support-Chatbot, KI-Chatbot

Ist es kostenpflichtig?

Dieser Workflow ist völlig kostenlos. Beachten Sie jedoch, dass Drittanbieterdienste (wie OpenAI API), die im Workflow verwendet werden, möglicherweise kostenpflichtig sind.

Workflow-Informationen
Schwierigkeitsgrad
Fortgeschritten
Anzahl der Nodes15
Kategorie2
Node-Typen9
Schwierigkeitsbeschreibung

Für erfahrene Benutzer, mittelkomplexe Workflows mit 6-15 Nodes

Autor
Yusuke Yamamoto

Yusuke Yamamoto

@yusuke-yamamoto

Business creator from Tokyo. Designing AI-driven automations that enhance marketing, reporting, and daily operations. I turn complex workflows into simple, elegant automations with n8n.

Externe Links
Auf n8n.io ansehen

Diesen Workflow teilen

Kategorien

Kategorien: 34