{
  "name": "Bulwark — Escalation to human",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "bulwark-escalation",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "a1b2c3d4-0001-4000-8000-000000000001",
      "name": "Webhook — escalation fired",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [0, 0]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "loose" },
          "conditions": [
            {
              "id": "rage-condition",
              "leftValue": "={{ $json.reason }}",
              "rightValue": "negative_sentiment",
              "operator": { "type": "string", "operation": "equals" }
            }
          ],
          "combinator": "or"
        },
        "options": {}
      },
      "id": "a1b2c3d4-0002-4000-8000-000000000002",
      "name": "Priority?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [220, 0]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            { "id": "f1", "name": "priority", "value": "P1 — angry customer", "type": "string" },
            { "id": "f2", "name": "slack_channel", "value": "#support-urgent", "type": "string" }
          ]
        },
        "options": {}
      },
      "id": "a1b2c3d4-0003-4000-8000-000000000003",
      "name": "Set P1 priority",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [440, -100]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            { "id": "f3", "name": "priority", "value": "P2 — standard", "type": "string" },
            { "id": "f4", "name": "slack_channel", "value": "#support", "type": "string" }
          ]
        },
        "options": {}
      },
      "id": "a1b2c3d4-0004-4000-8000-000000000004",
      "name": "Set P2 priority",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [440, 100]
    },
    {
      "parameters": {
        "channel": "={{ $json.slack_channel }}",
        "text": "=🚨 *Escalation {{ $json.ticket_id }}* ({{ $json.priority }})\n*Reason:* {{ $json.reason }}\n*Language:* {{ $json.lang }}\n*Question:* {{ $json.question }}\n_Agent could not or should not answer — human needed._",
        "otherOptions": {}
      },
      "id": "a1b2c3d4-0005-4000-8000-000000000005",
      "name": "Post to Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [680, 0],
      "credentials": {
        "slackApi": { "id": "REPLACE_ME", "name": "Support Slack workspace" }
      }
    },
    {
      "parameters": {
        "respondBody": "={{ JSON.stringify({ ok: true, ticket_id: $json.ticket_id, priority: $json.priority }) }}",
        "options": {}
      },
      "id": "a1b2c3d4-0006-4000-8000-000000000006",
      "name": "Respond to backend",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [900, 0]
    }
  ],
  "connections": {
    "Webhook — escalation fired": {
      "main": [[{ "node": "Priority?", "type": "main", "index": 0 }]]
    },
    "Priority?": {
      "main": [
        [{ "node": "Set P1 priority", "type": "main", "index": 0 }],
        [{ "node": "Set P2 priority", "type": "main", "index": 0 }]
      ]
    },
    "Set P1 priority": {
      "main": [[{ "node": "Post to Slack", "type": "main", "index": 0 }]]
    },
    "Set P2 priority": {
      "main": [[{ "node": "Post to Slack", "type": "main", "index": 0 }]]
    },
    "Post to Slack": {
      "main": [[{ "node": "Respond to backend", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "tags": ["bulwark", "demo"]
}
