Robot de estado DHL de múltiples canales

Intermedio

Este es unSupport Chatbot, AI Chatbotflujo de automatización del dominio deautomatización que contiene 15 nodos.Utiliza principalmente nodos como If, Code, Gmail, Merge, Webhook. Bot de seguimiento automatizado de paquetes DHL para formularios web y consultas por correo

Requisitos previos
  • Cuenta de Google y credenciales de API de Gmail
  • Punto final de HTTP Webhook (n8n generará automáticamente)
  • Pueden requerirse credenciales de autenticación para la API de destino
Vista previa del flujo de trabajo
Visualización de las conexiones entre nodos, con soporte para zoom y panorámica
Exportar flujo de trabajo
Copie la siguiente configuración JSON en n8n para importar y usar este flujo de trabajo
{
  "id": "sKPt2XLNb9anT2fW",
  "meta": {
    "instanceId": "15d6057a37b8367f33882dd60593ee5f6cc0c59310ff1dc66b626d726083b48d"
  },
  "name": "Multi-Channel DHL Status Bot with n8n, Gmail, and Webhooks",
  "tags": [],
  "nodes": [
    {
      "id": "intro-note-1",
      "name": "Resumen del Flujo de Trabajo",
      "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 Form 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 Email 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": "Configuración del Disparador",
      "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": "Unificar Disparadores",
      "type": "n8n-nodes-base.merge",
      "position": [
        608,
        208
      ],
      "parameters": {
        "mode": "combine",
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "extract-tracking",
      "name": "Extraer Número de Seguimiento",
      "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": "Lógica de Extracción",
      "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": "Obtener Estado de Seguimiento 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": "Configuración DHL API",
      "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": "Formatear Mensaje de Respuesta",
      "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": "Verificar Fuente",
      "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": "Enrutamiento de Respuesta",
      "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 Response",
      "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": "Enviar Respuesta 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": "Configuración de Correo",
      "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
          }
        ]
      ]
    }
  }
}
Preguntas frecuentes

¿Cómo usar este flujo de trabajo?

Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.

¿En qué escenarios es adecuado este flujo de trabajo?

Intermedio - Chatbot de soporte, Chatbot de IA

¿Es de pago?

Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.

Información del flujo de trabajo
Nivel de dificultad
Intermedio
Número de nodos15
Categoría2
Tipos de nodos9
Descripción de la dificultad

Adecuado para usuarios con experiencia intermedia, flujos de trabajo de complejidad media con 6-15 nodos

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.

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34