{
  "name": "08 · DevOps & Monitoring / Incident Auto-Bridge",
  "active": false,
  "nodes": [
    {
      "id": "00914af3-b1f0-46a0-b7ca-701a38e5306a",
      "name": "📘 Guide",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -640,
        -120
      ],
      "parameters": {
        "content": "## 08 · DevOps & Monitoring · Incident Auto-Bridge\n\n### What this does\nAlertmanager/Grafana webhook → severity route → PagerDuty + Slack war room + status page stub.\n\n### Setup checklist\n1. Alert source webhook\n2. PagerDuty/Slack\n3. Status page API\n\n### How to test locally\nPOST `ops-incident` with alert JSON.\n\n### Tips\n- Keep credentials in n8n Credentials (never hardcode secrets).\n- Use **Test URL** on the Webhook while developing.\n- Activate only after credentials + destinations are configured.\n",
        "width": 560,
        "height": 560,
        "color": 8
      }
    },
    {
      "id": "a030686d-ed62-4e3d-993a-bd0269e5f813",
      "name": "⚙️ Config",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -640,
        480
      ],
      "parameters": {
        "content": "## Config map\n\n- **Webhook path:** `ops-incident`\n- **Replace** all `https://httpbin.org/...` calls with real integrations.\n- **Credentials:** create in n8n → Credentials, then select on HTTP nodes.\n- **Activate** workflow only after a successful Test execution.\n\n### Local files\nShared host folder is mounted at `/files` inside n8n.",
        "width": 560,
        "height": 320,
        "color": 2
      }
    },
    {
      "id": "19a7d3df-5938-43bd-8db3-0ff260331034",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        200
      ],
      "webhookId": "58c7623c-d92f-4347-8374-943f815757eb",
      "parameters": {
        "httpMethod": "POST",
        "path": "ops-incident",
        "responseMode": "responseNode",
        "options": {}
      }
    },
    {
      "id": "788dacc6-2e59-4071-9855-0b917ab73d23",
      "name": "Normalize Payload",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        280,
        200
      ],
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "1",
              "name": "receivedAt",
              "value": "={{ $now.toISO() }}",
              "type": "string"
            },
            {
              "id": "2",
              "name": "source",
              "value": "08 · DevOps & Monitoring",
              "type": "string"
            },
            {
              "id": "3",
              "name": "workflow",
              "value": "Incident Auto-Bridge",
              "type": "string"
            },
            {
              "id": "4",
              "name": "payload",
              "value": "={{ $json.body || $json }}",
              "type": "object"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "dbcdee57-912d-4acd-aa5a-764f2c160406",
      "name": "Business Logic",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        560,
        200
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const item = $input.first().json;\nconst payload = item.payload || item;\nconst platforms = payload.platforms || ['primary', 'secondary', 'archive'];\nconst jobs = (Array.isArray(platforms) ? platforms : [platforms]).map((p, idx) => ({\n  json: {\n    ...item,\n    channel: p,\n    jobId: `${Date.now()}-${idx}`,\n    status: 'queued',\n    transformed: {\n      title: payload.title || payload.caption || payload.subject || defTitle(),\n      body: payload.body || payload.message || payload.caption || JSON.stringify(payload),\n      meta: payload.meta || {},\n    },\n  },\n}));\nreturn jobs.length ? jobs : [{ json: { ...item, channel: 'primary', status: 'queued' } }];\nfunction defTitle(){ return 'Incident Auto-Bridge'; }\n"
      }
    },
    {
      "id": "66944ee7-e648-42df-b9ea-6a2cc07ccb86",
      "name": "Ready to Dispatch?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        840,
        200
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "a08bdd7f-edc3-44b9-90f0-6ffb7e95c4ce",
              "leftValue": "={{ $json.status === \"queued\" }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "ac477fe2-b6e9-4017-a225-a58af74eaf43",
      "name": "Dispatch A (replace me)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1120,
        80
      ],
      "parameters": {
        "method": "POST",
        "url": "https://httpbin.org/post",
        "options": {},
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json) }}"
      }
    },
    {
      "id": "874d8926-4695-4225-a154-9430f614ec6c",
      "name": "Dispatch B (replace me)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1120,
        320
      ],
      "parameters": {
        "method": "POST",
        "url": "https://httpbin.org/post",
        "options": {},
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json) }}"
      }
    },
    {
      "id": "a9a44935-98f1-433f-b9b6-6efbf31cef5c",
      "name": "Aggregate Results",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1400,
        200
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const items = $input.all().map(i => i.json);\nreturn [{ json: { ok: true, workflow: 'Incident Auto-Bridge', count: items.length, results: items } }];"
      }
    },
    {
      "id": "7f1b69fc-60a0-4a30-b2c5-bc36fce11068",
      "name": "Webhook Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1680,
        200
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $json }}",
        "options": {}
      }
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Normalize Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Payload": {
      "main": [
        [
          {
            "node": "Business Logic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Business Logic": {
      "main": [
        [
          {
            "node": "Ready to Dispatch?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ready to Dispatch?": {
      "main": [
        [
          {
            "node": "Dispatch A (replace me)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Dispatch B (replace me)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dispatch A (replace me)": {
      "main": [
        [
          {
            "node": "Aggregate Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Dispatch B (replace me)": {
      "main": [
        [
          {
            "node": "Aggregate Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Results": {
      "main": [
        [
          {
            "node": "Webhook Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner"
  },
  "tags": [],
  "meta": {
    "templateCredsSetupCompleted": true,
    "description": "Alertmanager/Grafana webhook → severity route → PagerDuty + Slack war room + status page stub."
  },
  "pinData": {}
}