{
  "id": "CODWF06DashboardEvents",
  "name": "COD · WF-06 Dashboard Events",
  "active": false,
  "nodes": [
    { "parameters": { "content": "## Dashboard Event Fan-Out\nReceive authenticated dashboard side effects, fetch canonical order/customer data, map the event to the reusable notification contract, and deliver without coupling the UI to providers.", "height": 210, "width": 1200, "color": 2 }, "id": "wf06-note", "name": "Dashboard Event Gateway", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1, "position": [-700, -300] },
    { "parameters": { "httpMethod": "POST", "path": "dashboard-events", "authentication": "headerAuth", "responseMode": "responseNode", "options": {} }, "id": "wf06-webhook", "name": "Dashboard Events Webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2.1, "position": [-640, 0], "webhookId": "cod-dashboard-events-v1", "credentials": { "httpHeaderAuth": { "id": "cred_internal_token", "name": "COD Dashboard Event Token" } } },
    { "parameters": { "respondWith": "json", "responseBody": "={{ { accepted: true } }}", "options": { "responseCode": 202 } }, "id": "wf06-response", "name": "Respond Event Accepted", "type": "n8n-nodes-base.respondToWebhook", "typeVersion": 1.5, "position": [-400, -180] },
    { "parameters": { "rules": { "values": [
      { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2 }, "conditions": [{ "id": "wf06-status", "leftValue": "={{ $json.body.event }}", "rightValue": "ORDER_STATUS_CHANGED", "operator": { "type": "string", "operation": "equals" } }], "combinator": "and" }, "renameOutput": true, "outputKey": "Status" },
      { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2 }, "conditions": [{ "id": "wf06-resend", "leftValue": "={{ $json.body.event }}", "rightValue": "RESEND_CONFIRMATION", "operator": { "type": "string", "operation": "equals" } }], "combinator": "and" }, "renameOutput": true, "outputKey": "Resend" },
      { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2 }, "conditions": [{ "id": "wf06-address", "leftValue": "={{ $json.body.event }}", "rightValue": "ADDRESS_UPDATED", "operator": { "type": "string", "operation": "equals" } }], "combinator": "and" }, "renameOutput": true, "outputKey": "Address" },
      { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2 }, "conditions": [{ "id": "wf06-stock", "leftValue": "={{ $json.body.event }}", "rightValue": "LOW_STOCK", "operator": { "type": "string", "operation": "equals" } }], "combinator": "and" }, "renameOutput": true, "outputKey": "Low Stock" }
    ] }, "options": { "fallbackOutput": "none" } }, "id": "wf06-switch", "name": "Event Switch", "type": "n8n-nodes-base.switch", "typeVersion": 3.4, "position": [-400, 20] },
    { "parameters": { "url": "={{ $env.INTERNAL_API_URL }}/api/internal/orders/{{ $('Dashboard Events Webhook').item.json.body.orderId }}", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "options": { "timeout": 10000 } }, "id": "wf06-order", "name": "Fetch Event Order", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [-120, 20], "retryOnFail": true, "maxTries": 3, "waitBetweenTries": 1000, "credentials": { "httpHeaderAuth": { "id": "cred_internal_api", "name": "COD Internal API Bearer" } } },
    { "parameters": { "assignments": { "assignments": [{ "id": "wf06-event", "name": "event", "value": "={{ $('Dashboard Events Webhook').item.json.body }}", "type": "object" }, { "id": "wf06-order-value", "name": "order", "value": "={{ $json }}", "type": "object" }] }, "options": {} }, "id": "wf06-context", "name": "Merge Dashboard Event & Order", "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [120, 20] },
    { "parameters": { "jsCode": "@@code:dashboard-event" }, "id": "wf06-map", "name": "Map Event to Notification", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [360, 20] },
    { "parameters": { "workflowId": { "__rl": true, "value": "CODWF00SendNotification", "mode": "id" }, "mode": "once", "options": { "waitForSubWorkflow": true } }, "id": "wf06-send", "name": "Send Dashboard Event Notification", "type": "n8n-nodes-base.executeWorkflow", "typeVersion": 1.3, "position": [600, 20] }
  ],
  "connections": {
    "Dashboard Events Webhook": { "main": [[{ "node": "Respond Event Accepted", "type": "main", "index": 0 }, { "node": "Event Switch", "type": "main", "index": 0 }]] },
    "Event Switch": { "main": [[{ "node": "Fetch Event Order", "type": "main", "index": 0 }], [{ "node": "Fetch Event Order", "type": "main", "index": 0 }], [{ "node": "Fetch Event Order", "type": "main", "index": 0 }], [{ "node": "Fetch Event Order", "type": "main", "index": 0 }]] },
    "Fetch Event Order": { "main": [[{ "node": "Merge Dashboard Event & Order", "type": "main", "index": 0 }]] },
    "Merge Dashboard Event & Order": { "main": [[{ "node": "Map Event to Notification", "type": "main", "index": 0 }]] },
    "Map Event to Notification": { "main": [[{ "node": "Send Dashboard Event Notification", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1", "errorWorkflow": "CODWF99ErrorHandler", "timezone": "Africa/Cairo" }, "versionId": "f0600000-0000-4000-8000-000000000000", "meta": { "templateCredsSetupCompleted": true }, "tags": []
}
