{
  "name": "Draft and track incident postmortems with OpenAI, Google Sheets, Discord and Gmail",
  "nodes": [
    {
      "id": "c2926fe1-1430-4395-9c2b-cf3a6022d432",
      "name": "When Incident Report Submitted",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        304,
        1024
      ],
      "parameters": {
        "options": {},
        "formTitle": "Incident Report",
        "formFields": {
          "values": [
            {
              "fieldName": "reporter_name",
              "fieldLabel": "Your name",
              "placeholder": "e.g. Dina Wijaya",
              "requiredField": true
            },
            {
              "fieldName": "reporter_email",
              "fieldType": "email",
              "fieldLabel": "Your email",
              "placeholder": "user@example.com",
              "requiredField": true
            },
            {
              "fieldName": "incident_title",
              "fieldLabel": "Incident title",
              "placeholder": "e.g. Checkout API timeouts",
              "requiredField": true
            },
            {
              "fieldName": "severity",
              "fieldType": "dropdown",
              "fieldLabel": "Severity",
              "fieldOptions": {
                "values": [
                  {
                    "option": "low"
                  },
                  {
                    "option": "medium"
                  },
                  {
                    "option": "high"
                  },
                  {
                    "option": "critical"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldName": "impacted_service",
              "fieldLabel": "Impacted service",
              "placeholder": "e.g. checkout-service",
              "requiredField": true
            },
            {
              "fieldName": "started_at",
              "fieldLabel": "When did it start",
              "placeholder": "e.g. 2026-08-14 14:30 UTC"
            },
            {
              "fieldName": "summary",
              "fieldType": "textarea",
              "fieldLabel": "What happened",
              "placeholder": "What happened, who was affected, and for how long?",
              "requiredField": true
            },
            {
              "fieldName": "root_cause_candidate",
              "fieldType": "textarea",
              "fieldLabel": "Suspected cause",
              "placeholder": "What do you suspect caused it?"
            },
            {
              "fieldName": "actions_taken",
              "fieldType": "textarea",
              "fieldLabel": "Actions taken",
              "placeholder": "What was done to mitigate or resolve it?"
            }
          ]
        },
        "formDescription": "Report an incident so the team can draft a postmortem, track action items, and follow up on fixes."
      },
      "typeVersion": 2.6
    },
    {
      "id": "d4938311-11d3-4bca-9489-13155d207f5c",
      "name": "Normalize Incident Data",
      "type": "n8n-nodes-base.set",
      "position": [
        528,
        1024
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "n1",
              "name": "incident_id",
              "type": "string",
              "value": "={{ 'INC-' + Date.now() }}"
            },
            {
              "id": "n2",
              "name": "received_at",
              "type": "string",
              "value": "={{ $now.toISO() }}"
            },
            {
              "id": "n3",
              "name": "status",
              "type": "string",
              "value": "OPEN"
            },
            {
              "id": "n4",
              "name": "reporter_name",
              "type": "string",
              "value": "={{ $json.reporter_name }}"
            },
            {
              "id": "n5",
              "name": "reporter_email",
              "type": "string",
              "value": "={{ $json.reporter_email }}"
            },
            {
              "id": "n6",
              "name": "incident_title",
              "type": "string",
              "value": "={{ $json.incident_title }}"
            },
            {
              "id": "n7",
              "name": "severity",
              "type": "string",
              "value": "={{ $json.severity }}"
            },
            {
              "id": "n8",
              "name": "impacted_service",
              "type": "string",
              "value": "={{ $json.impacted_service }}"
            },
            {
              "id": "n9",
              "name": "started_at",
              "type": "string",
              "value": "={{ $json.started_at || '' }}"
            },
            {
              "id": "n10",
              "name": "summary",
              "type": "string",
              "value": "={{ $json.summary }}"
            },
            {
              "id": "n11",
              "name": "root_cause_candidate",
              "type": "string",
              "value": "={{ $json.root_cause_candidate || '' }}"
            },
            {
              "id": "n12",
              "name": "actions_taken",
              "type": "string",
              "value": "={{ $json.actions_taken || '' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c24aea54-542e-4d6c-a7c9-969b4c945731",
      "name": "Validate Incident Input",
      "type": "n8n-nodes-base.if",
      "position": [
        752,
        1024
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "v1",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.incident_title }}",
              "rightValue": ""
            },
            {
              "id": "v2",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.summary }}",
              "rightValue": ""
            },
            {
              "id": "v3",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.severity }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "e25131cc-3a19-49e8-8895-bf76a1ef0004",
      "name": "Acknowledge Reporter by Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        928,
        896
      ],
      "parameters": {
        "sendTo": "={{ $json.reporter_email }}",
        "message": "={{ 'Hi ' + $json.reporter_name + ',\\n\\nYour incident report has been received. Our team is reviewing it.\\n\\nTitle: ' + $json.incident_title + '\\nSeverity: ' + $json.severity + '\\nService: ' + $json.impacted_service + '\\nIncident ID: ' + $json.incident_id + '\\n\\nA postmortem draft will be prepared shortly. You will receive updates by email.\\n\\nBest regards,\\nIncident Response Team' }}",
        "options": {},
        "subject": "={{ 'Incident received: ' + $json.incident_title + ' (' + $json.incident_id + ')' }}",
        "emailType": "text"
      },
      "typeVersion": 2.2
    },
    {
      "id": "eaf6791d-82e7-47fe-93a3-f8fed8ae8de6",
      "name": "AI Postmortem Writer",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2048,
        1440
      ],
      "parameters": {
        "text": "={{ 'Incident details: ' + JSON.stringify($json) + '. Also classify root_cause_type as one of: deployment, config, dependency, capacity, code, data, security, unknown. Add sla_hours: number (critical: 4, high: 24, medium: 72, low: 168).' }}",
        "options": {
          "systemMessage": "You are an incident postmortem writer for a software team. Write clear, blameless postmortem content based on the incident details. Return ONLY valid JSON with exactly these keys: overview (string, 2-3 sentences), timeline (string, a short bullet-style list of key moments), root_cause (string, 2-3 sentences), root_cause_type (string, one of: deployment, config, dependency, capacity, code, data, security, unknown), impact (string, 1-2 sentences), action_items (string, one action item per line in the format 'Owner: <name> | Due: <YYYY-MM-DD> | <task>'; write 2-4 realistic action items), digest (string, 2 sentences for a team notification), sla_hours (number). Do not use markdown code fences, return the raw JSON object only."
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "c2cf2f33-8279-4206-9b9a-96fa98e633dc",
      "name": "OpenAI DeepSeek Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2112,
        1632
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "deepseek-v4-flash",
          "cachedResultName": "deepseek-v4-flash"
        },
        "options": {
          "temperature": 0.2
        },
        "builtInTools": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "16c6b5c2-2ae8-4dad-9a12-710765d05521",
      "name": "Parse Postmortem JSON",
      "type": "n8n-nodes-base.set",
      "position": [
        2400,
        1504
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "p0",
              "name": "overview",
              "type": "string",
              "value": "={{ JSON.parse(($json.output || '{}').replace(/```/g, '')).overview || '' }}"
            },
            {
              "id": "p1",
              "name": "timeline",
              "type": "string",
              "value": "={{ JSON.parse(($json.output || '{}').replace(/```/g, '')).timeline || '' }}"
            },
            {
              "id": "p2",
              "name": "root_cause",
              "type": "string",
              "value": "={{ JSON.parse(($json.output || '{}').replace(/```/g, '')).root_cause || '' }}"
            },
            {
              "id": "p3",
              "name": "root_cause_type",
              "type": "string",
              "value": "={{ JSON.parse(($json.output || '{}').replace(/```/g, '')).root_cause_type || 'unknown' }}"
            },
            {
              "id": "p4",
              "name": "impact",
              "type": "string",
              "value": "={{ JSON.parse(($json.output || '{}').replace(/```/g, '')).impact || '' }}"
            },
            {
              "id": "p5",
              "name": "action_items",
              "type": "string",
              "value": "={{ JSON.parse(($json.output || '{}').replace(/```/g, '')).action_items || '' }}"
            },
            {
              "id": "p6",
              "name": "digest",
              "type": "string",
              "value": "={{ JSON.parse(($json.output || '{}').replace(/```/g, '')).digest || '' }}"
            },
            {
              "id": "p7",
              "name": "sla_hours",
              "type": "number",
              "value": "={{ JSON.parse(($json.output || '{}').replace(/```/g, '')).sla_hours || 24 }}"
            },
            {
              "id": "k0",
              "name": "incident_id",
              "type": "string",
              "value": "={{ $('Normalize Incident Data').item.json.incident_id }}"
            },
            {
              "id": "k1",
              "name": "incident_title",
              "type": "string",
              "value": "={{ $('Normalize Incident Data').item.json.incident_title }}"
            },
            {
              "id": "k2",
              "name": "severity",
              "type": "string",
              "value": "={{ $('Normalize Incident Data').item.json.severity }}"
            },
            {
              "id": "k3",
              "name": "impacted_service",
              "type": "string",
              "value": "={{ $('Normalize Incident Data').item.json.impacted_service }}"
            },
            {
              "id": "k4",
              "name": "reporter_name",
              "type": "string",
              "value": "={{ $('Normalize Incident Data').item.json.reporter_name }}"
            },
            {
              "id": "k5",
              "name": "reporter_email",
              "type": "string",
              "value": "={{ $('Normalize Incident Data').item.json.reporter_email }}"
            },
            {
              "id": "k6",
              "name": "summary",
              "type": "string",
              "value": "={{ $('Normalize Incident Data').item.json.summary }}"
            },
            {
              "id": "k7",
              "name": "started_at",
              "type": "string",
              "value": "={{ $('Normalize Incident Data').item.json.started_at }}"
            },
            {
              "id": "k8",
              "name": "received_at",
              "type": "string",
              "value": "={{ $('Normalize Incident Data').item.json.received_at }}"
            },
            {
              "id": "k9",
              "name": "status",
              "type": "string",
              "value": "={{ $('Normalize Incident Data').item.json.status }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "0624bc60-a74b-4e8e-89a8-89ff4d29f4ee",
      "name": "Append Postmortem to Log",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2624,
        1264
      ],
      "parameters": {
        "columns": {
          "value": {
            "digest": "={{ $json.digest }}",
            "impact": "={{ $json.impact }}",
            "status": "={{ $json.status }}",
            "summary": "={{ $json.summary }}",
            "overview": "={{ $json.overview }}",
            "severity": "={{ $json.severity }}",
            "timeline": "={{ $json.timeline }}",
            "sla_hours": "={{ $json.sla_hours }}",
            "created_at": "={{ $json.received_at }}",
            "root_cause": "={{ $json.root_cause }}",
            "incident_id": "={{ $json.incident_id }}",
            "action_items": "={{ $json.action_items }}",
            "reporter_name": "={{ $json.reporter_name }}",
            "incident_title": "={{ $json.incident_title }}",
            "reporter_email": "={{ $json.reporter_email }}",
            "root_cause_type": "={{ $json.root_cause_type }}",
            "impacted_service": "={{ $json.impacted_service }}"
          },
          "schema": [
            {
              "id": "incident_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "incident_id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "incident_title",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "incident_title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "severity",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "severity",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "impacted_service",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "impacted_service",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reporter_name",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "reporter_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reporter_email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "reporter_email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "summary",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "summary",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "overview",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "overview",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "timeline",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "timeline",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "root_cause",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "root_cause",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "root_cause_type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "root_cause_type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "impact",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "impact",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "action_items",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "action_items",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "digest",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "digest",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "sla_hours",
              "type": "number",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "sla_hours",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "created_at",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "created_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": []
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Postmortems"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "1Rus2mc3x4wEfkVxo76QaGCaCjFYfkDHsikLZ3ChRHc4"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "71f97494-6ead-4e1f-98fa-f04028de7e86",
      "name": "Extract Action Items",
      "type": "n8n-nodes-base.code",
      "position": [
        2848,
        1264
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst out = [];\nfor (const it of items) {\n  const j = it.json;\n  const lines = String(j.action_items || '')\n    .split('\\n')\n    .map((l) => l.replace(/^\\s*[-*\\u2022]\\s*/, '').trim())\n    .filter((l) => l.length > 0);\n  if (lines.length === 0) {\n    out.push({ json: { incident_id: j.incident_id || '', incident_title: j.incident_title || '', item_text: 'No action items', owner: '', due_date: '', status: 'OPEN', reporter_email: j.reporter_email || '', created_at: j.received_at || '' } });\n  } else {\n    for (const line of lines) {\n      let owner = '';\n      let due = '';\n      const mO = line.match(/owner:\\s*([^|]+)/i);\n      const mD = line.match(/due:\\s*(\\d{4}-\\d{2}-\\d{2})/i);\n      if (mO) { owner = mO[1].trim(); }\n      if (mD) { due = mD[1].trim(); }\n      out.push({ json: { incident_id: j.incident_id || '', incident_title: j.incident_title || '', item_text: line, owner: owner, due_date: due, status: 'OPEN', reporter_email: j.reporter_email || '', created_at: j.received_at || '' } });\n    }\n  }\n}\nreturn out;"
      },
      "typeVersion": 2
    },
    {
      "id": "6ba6ce74-869c-48e7-b2a0-192d4215f79e",
      "name": "Append Action Items to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3072,
        1264
      ],
      "parameters": {
        "columns": {
          "value": {
            "owner": "={{ $json.owner }}",
            "status": "={{ $json.status }}",
            "due_date": "={{ $json.due_date }}",
            "item_text": "={{ $json.item_text }}",
            "created_at": "={{ $json.created_at }}",
            "incident_id": "={{ $json.incident_id }}",
            "incident_title": "={{ $json.incident_title }}",
            "reporter_email": "={{ $json.reporter_email }}"
          },
          "schema": [
            {
              "id": "incident_id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "incident_id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "incident_title",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "incident_title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "item_text",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "item_text",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "owner",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "owner",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "due_date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "due_date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reporter_email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "reporter_email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "created_at",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "created_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": []
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "ActionItems"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "1Rus2mc3x4wEfkVxo76QaGCaCjFYfkDHsikLZ3ChRHc4"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "aad1f2aa-e00e-4856-bbc5-efdf8b6ee58d",
      "name": "Email Postmortem to Stakeholders",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2624,
        1744
      ],
      "parameters": {
        "sendTo": "={{ $json.reporter_email }}",
        "message": "={{ 'Postmortem: ' + $json.incident_title + '\\nSeverity: ' + $json.severity + '\\nService: ' + $json.impacted_service + '\\nReporter: ' + $json.reporter_name + '\\nIncident ID: ' + $json.incident_id + '\\nRoot cause type: ' + $json.root_cause_type + '\\n\\nOverview\\n' + $json.overview + '\\n\\nTimeline\\n' + $json.timeline + '\\n\\nRoot cause\\n' + $json.root_cause + '\\n\\nImpact\\n' + $json.impact + '\\n\\nAction items\\n' + $json.action_items }}",
        "options": {},
        "subject": "={{ 'Postmortem: ' + $json.incident_title + ' (' + $json.severity + ')' }}",
        "emailType": "text"
      },
      "typeVersion": 2.2
    },
    {
      "id": "9a9b199c-22de-442a-9d91-eca405f26191",
      "name": "If High or Critical Severity",
      "type": "n8n-nodes-base.if",
      "position": [
        2624,
        1552
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "s1",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.severity }}",
              "rightValue": "high"
            },
            {
              "id": "s2",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.severity }}",
              "rightValue": "critical"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "5069d9b3-e36f-4299-b7d0-c942dfad33e2",
      "name": "Alert On-Call on Discord",
      "type": "n8n-nodes-base.discord",
      "position": [
        2848,
        1648
      ],
      "parameters": {
        "content": "={{ '\ud83d\udea8 High severity postmortem drafted\\nIncident: ' + $json.incident_title + ' (' + $json.severity + ')\\nService: ' + $json.impacted_service + '\\nRoot cause type: ' + $json.root_cause_type + '\\nSLA hours: ' + $json.sla_hours + '\\nID: ' + $json.incident_id + '\\n\\n' + $json.digest + '\\n\\nFull draft emailed to stakeholders.' }}",
        "guildId": {
          "__rl": true,
          "mode": "list",
          "value": "1409061244454965312",
          "cachedResultName": "Jakserver"
        },
        "options": {},
        "resource": "message",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "1409061827827994645",
          "cachedResultName": "form-contact"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "2bd03d97-6b01-4f26-b8be-c0cbba15e8a9",
      "name": "Post Postmortem Digest on Discord",
      "type": "n8n-nodes-base.discord",
      "position": [
        2848,
        1456
      ],
      "parameters": {
        "content": "={{ '\ud83d\udcdd Postmortem drafted\\nIncident: ' + $json.incident_title + ' (' + $json.severity + ')\\nService: ' + $json.impacted_service + '\\nRoot cause type: ' + $json.root_cause_type + '\\nID: ' + $json.incident_id + '\\n\\n' + $json.digest }}",
        "guildId": {
          "__rl": true,
          "mode": "list",
          "value": "1409061244454965312",
          "cachedResultName": "Jakserver"
        },
        "options": {},
        "resource": "message",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "1409061827827994645",
          "cachedResultName": "form-contact"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "fc30d7fc-e1e3-4c14-a735-19a94b54f376",
      "name": "Weekly Follow-up Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        272,
        1568
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 * * 1"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "46e9e631-d5d7-4fa1-9246-bd1c90312c7e",
      "name": "Read Open Action Items",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        496,
        1568
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "ActionItems"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "1Rus2mc3x4wEfkVxo76QaGCaCjFYfkDHsikLZ3ChRHc4"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "91bae50c-8c5b-417b-83ae-6a5d043bf5b9",
      "name": "Prepare Weekly Follow-up",
      "type": "n8n-nodes-base.code",
      "position": [
        720,
        1568
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst now = Date.now();\nconst open = items.filter((i) => String(i.json.status || '').toUpperCase() === 'OPEN');\nif (open.length === 0) {\n  return [{ json: { no_open: true } }];\n}\nconst out = [];\nfor (const it of open) {\n  const j = it.json;\n  let is_overdue = false;\n  let due = String(j.due_date || '').trim();\n  if (due) {\n    const d = new Date(due);\n    if (!isNaN(d.getTime()) && d.getTime() < now) { is_overdue = true; }\n  }\n  out.push({\n    json: {\n      incident_id: j.incident_id || '',\n      incident_title: j.incident_title || '',\n      item_text: j.item_text || '',\n      owner: j.owner || '',\n      due_date: due,\n      status: 'OPEN',\n      reporter_email: j.reporter_email || '',\n      is_overdue: is_overdue,\n      line: (j.incident_title || '') + ' | ' + (j.item_text || '') + ' | Owner: ' + (j.owner || 'n/a') + ' | Due: ' + (due || 'n/a') + (is_overdue ? ' | OVERDUE' : '')\n    }\n  });\n}\nreturn out;"
      },
      "typeVersion": 2
    },
    {
      "id": "b15f4008-a5c5-47f9-9050-27d30a017e40",
      "name": "If No Open Items",
      "type": "n8n-nodes-base.if",
      "position": [
        944,
        1568
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "no1",
              "operator": {
                "type": "boolean",
                "operation": "true"
              },
              "leftValue": "={{ $json.no_open === true }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "5197032b-6d2d-4921-ba1b-b4d015e29bfb",
      "name": "If Item Is Overdue",
      "type": "n8n-nodes-base.if",
      "position": [
        1168,
        1472
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "od1",
              "operator": {
                "type": "boolean",
                "operation": "true"
              },
              "leftValue": "={{ $json.is_overdue === true }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "f6b3e2ab-6e66-4416-8d4a-a016274b7d63",
      "name": "Email Overdue Reminder to Owner",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1392,
        1472
      ],
      "parameters": {
        "sendTo": "={{ $json.reporter_email || 'user@example.com' }}",
        "message": "={{ 'Hi team,\\n\\nThis action item from incident postmortem is overdue:\\n\\nIncident: ' + $json.incident_title + '\\nAction item: ' + $json.item_text + '\\nOwner: ' + $json.owner + '\\nDue: ' + $json.due_date + '\\n\\nPlease update the status in the ActionItems sheet once it is done.\\n\\nBest regards,\\nIncident Response Team' }}",
        "options": {},
        "subject": "={{ 'Overdue action item: ' + $json.item_text }}",
        "emailType": "text"
      },
      "typeVersion": 2.2
    },
    {
      "id": "a976d726-0bac-4e3d-b41f-81afcd403e8c",
      "name": "Alert Overdue on Discord",
      "type": "n8n-nodes-base.discord",
      "position": [
        1616,
        1472
      ],
      "parameters": {
        "content": "={{ '\u23f0 Overdue action item\\nIncident: ' + $json.incident_title + '\\nItem: ' + $json.item_text + '\\nOwner: ' + $json.owner + '\\nDue: ' + $json.due_date }}",
        "guildId": {
          "__rl": true,
          "mode": "list",
          "value": "1409061244454965312",
          "cachedResultName": "Jakserver"
        },
        "options": {},
        "resource": "message",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "1409061827827994645",
          "cachedResultName": "form-contact"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "7b10e23e-a312-48bb-98bc-e2bbeddf82aa",
      "name": "Discord All Clear",
      "type": "n8n-nodes-base.discord",
      "position": [
        1168,
        1664
      ],
      "parameters": {
        "content": "\u2705 No open action items this week. Nice work keeping incidents closed out!",
        "guildId": {
          "__rl": true,
          "mode": "list",
          "value": "1409061244454965312",
          "cachedResultName": "Jakserver"
        },
        "options": {},
        "resource": "message",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "1409061827827994645",
          "cachedResultName": "form-contact"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "cca8e31f-f05f-4173-b51a-433563f9026e",
      "name": "Monthly RCA Trend Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        2032,
        736
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 1 * *"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f71ea15e-d582-475e-a08f-bd55f183a4a9",
      "name": "Read Postmortems",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2256,
        736
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Postmortems"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "1Rus2mc3x4wEfkVxo76QaGCaCjFYfkDHsikLZ3ChRHc4"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "3bcfb65b-2073-4c29-883b-abc3e83cbe20",
      "name": "Filter Current Month",
      "type": "n8n-nodes-base.code",
      "position": [
        2480,
        736
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst now = new Date();\nconst firstOfMonth = new Date(now.getFullYear(), now.getMonth(), 1).getTime();\nconst filtered = items.filter((it) => {\n  const ts = new Date(it.json.created_at || 0).getTime();\n  return !isNaN(ts) && ts >= firstOfMonth;\n});\nreturn filtered;"
      },
      "typeVersion": 2
    },
    {
      "id": "e1675ff6-212b-4d1e-8395-99f2d17a45f7",
      "name": "Summarize Monthly RCA Trends",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2704,
        736
      ],
      "parameters": {
        "text": "={{ 'Summarize this month incident postmortems. Return ONLY valid JSON with keys: total (number), critical_count (number), top_root_cause_type (string), top_service (string), recurring_issues (string, max 60 words), key_takeaways (string, max 60 words). Data: ' + JSON.stringify($json) }}",
        "options": {
          "systemMessage": "You are an engineering reliability analyst. Summarize monthly incident trends from postmortems. Be concise."
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "b359143b-cd98-4ba8-b7b8-44b8cec905d9",
      "name": "OpenAI Monthly RCA Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2784,
        960
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "deepseek-v4-flash",
          "cachedResultName": "deepseek-v4-flash"
        },
        "options": {
          "temperature": 0.2
        },
        "builtInTools": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "168ef7e2-5377-42e8-936a-1b1974cb1e46",
      "name": "Send Monthly RCA Report",
      "type": "n8n-nodes-base.telegram",
      "position": [
        3056,
        736
      ],
      "parameters": {
        "text": "={{ '\ud83d\udcca Monthly Incident RCA Report\\nTotal: ' + $json.total + '\\nCritical: ' + $json.critical_count + '\\nTop root cause: ' + $json.top_root_cause_type + '\\nTop service: ' + $json.top_service + '\\nRecurring: ' + $json.recurring_issues + '\\nTakeaways: ' + $json.key_takeaways }}",
        "chatId": "123456789",
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "0823daad-5490-426c-9c61-fc6b245c0b79",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -432,
        368
      ],
      "parameters": {
        "width": 520,
        "height": 892,
        "content": "## Automate incident postmortems with AI, Google Sheets, Discord and Gmail\n\n### How it works\n\n1. A team member submits an incident report through the hosted form (what happened, severity, impacted service, suspected cause).\n2. The reporter gets an immediate acknowledgment email with the incident ID.\n3. The workflow validates the report, then an AI agent drafts a structured postmortem with overview, timeline, root cause (classified by type), impact, SLA hours and action items.\n4. The postmortem is saved to Google Sheets with root cause type and SLA, action items are tracked in their own sheet, and stakeholders get the full draft by email.\n5. High or critical incidents trigger an urgent Discord alert; other incidents get a digest post.\n6. Every Monday the workflow reviews open action items, emails owners about overdue items, and alerts the team on Discord.\n7. On the 1st of each month, a reliability report summarizes incident trends by root cause type and service.\n\n### Setup\n\n- Connect Google Sheets, Gmail, Discord, and OpenAI credentials.\n- Create a spreadsheet with Postmortems and ActionItems sheets, then update the two Google Sheets nodes.\n- Update the Discord channel and the stakeholder email addresses in the Gmail nodes.\n\n### Customization\n\n- Change the form fields, the AI prompt, the severity thresholds, or the weekly and monthly schedules to match your process."
      },
      "typeVersion": 1
    },
    {
      "id": "7e426bcf-aee7-47ad-8412-e8ce20c25ec3",
      "name": "Sticky Note: Intake",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        784
      ],
      "parameters": {
        "color": 7,
        "width": 1064,
        "height": 596,
        "content": "## Intake and validation\n\nTeam members submit incident reports through the form. The reporter gets an acknowledgment email and invalid reports alert the team."
      },
      "typeVersion": 1
    },
    {
      "id": "ef3f2367-75fa-4fd4-a083-2232bfd2af40",
      "name": "Sticky Note: AI drafting",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1904,
        1168
      ],
      "parameters": {
        "color": 7,
        "width": 1400,
        "height": 760,
        "content": "## AI drafting and logging\n\nAI turns the raw report into a structured postmortem with classified root cause, SLA hours and action items, saved to Google Sheets."
      },
      "typeVersion": 1
    },
    {
      "id": "abf479d9-1de8-4b2d-9f37-69d335d7c666",
      "name": "Sticky Note: Follow-up",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1968,
        608
      ],
      "parameters": {
        "color": 7,
        "width": 1316,
        "height": 500,
        "content": "## Notifications and follow-up\n\nHigh severity alerts on Discord, weekly overdue reminders, and a monthly RCA trend report to the team."
      },
      "typeVersion": 1
    },
    {
      "id": "db61242c-d79f-4139-abaf-5d0d1accdc7e",
      "name": "Alert Invalid Report on Discord",
      "type": "n8n-nodes-base.discord",
      "position": [
        928,
        1120
      ],
      "parameters": {
        "content": "={{ '\u26a0\ufe0f Invalid incident report\\nTitle: ' + $json.incident_title + '\\nReporter: ' + $json.reporter_name + '\\nMissing required fields (title, summary, or severity). Please fix and resubmit.' }}",
        "guildId": {
          "__rl": true,
          "mode": "list",
          "value": "1409061244454965312",
          "cachedResultName": "Jakserver"
        },
        "options": {},
        "resource": "message",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "1409061827827994645",
          "cachedResultName": "form-contact"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "71a75c4f-6bfc-4a43-bd5c-03423b3a3433",
      "name": "Email Reporter about Invalid Report",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1120,
        1120
      ],
      "parameters": {
        "sendTo": "={{ $json.reporter_email }}",
        "message": "={{ 'Hi ' + $json.reporter_name + ',\\n\\nWe could not process your incident report because the title, summary, or severity was missing.\\n\\nTitle submitted: ' + $json.incident_title + '\\n\\nPlease resubmit with a title, a short summary of what happened, and the severity.\\n\\nBest regards,\\nIncident Response Team' }}",
        "options": {},
        "subject": "Your incident report was incomplete",
        "emailType": "text"
      },
      "typeVersion": 2.2
    },
    {
      "id": "50f2d138-4828-401d-bff6-0fe57dda2649",
      "name": "Sticky Note: Follow-up1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        1424
      ],
      "parameters": {
        "color": 7,
        "width": 1636,
        "height": 500,
        "content": "## Weekly Notifications and follow-up\n\nHigh severity alerts on Discord, weekly overdue reminders, and a monthly RCA trend report to the team."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "If No Open Items": {
      "main": [
        [
          {
            "node": "Discord All Clear",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If Item Is Overdue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Postmortems": {
      "main": [
        [
          {
            "node": "Filter Current Month",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Item Is Overdue": {
      "main": [
        [
          {
            "node": "Email Overdue Reminder to Owner",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Postmortem Writer": {
      "main": [
        [
          {
            "node": "Parse Postmortem JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Action Items": {
      "main": [
        [
          {
            "node": "Append Action Items to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Current Month": {
      "main": [
        [
          {
            "node": "Summarize Monthly RCA Trends",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI DeepSeek Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Postmortem Writer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Parse Postmortem JSON": {
      "main": [
        [
          {
            "node": "Append Postmortem to Log",
            "type": "main",
            "index": 0
          },
          {
            "node": "Email Postmortem to Stakeholders",
            "type": "main",
            "index": 0
          },
          {
            "node": "If High or Critical Severity",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Open Action Items": {
      "main": [
        [
          {
            "node": "Prepare Weekly Follow-up",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Incident Data": {
      "main": [
        [
          {
            "node": "Validate Incident Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Incident Input": {
      "main": [
        [
          {
            "node": "Acknowledge Reporter by Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Alert Invalid Report on Discord",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append Postmortem to Log": {
      "main": [
        [
          {
            "node": "Extract Action Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Monthly RCA Model": {
      "ai_languageModel": [
        [
          {
            "node": "Summarize Monthly RCA Trends",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Weekly Follow-up": {
      "main": [
        [
          {
            "node": "If No Open Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Weekly Follow-up Trigger": {
      "main": [
        [
          {
            "node": "Read Open Action Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Monthly RCA Trend Trigger": {
      "main": [
        [
          {
            "node": "Read Postmortems",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If High or Critical Severity": {
      "main": [
        [
          {
            "node": "Alert On-Call on Discord",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Post Postmortem Digest on Discord",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize Monthly RCA Trends": {
      "main": [
        [
          {
            "node": "Send Monthly RCA Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Acknowledge Reporter by Email": {
      "main": [
        [
          {
            "node": "AI Postmortem Writer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Incident Report Submitted": {
      "main": [
        [
          {
            "node": "Normalize Incident Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Alert Invalid Report on Discord": {
      "main": [
        [
          {
            "node": "Email Reporter about Invalid Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Overdue Reminder to Owner": {
      "main": [
        [
          {
            "node": "Alert Overdue on Discord",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "instanceId": null
  },
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": false,
    "executionOrder": "v1"
  }
}