{
  "id": "oaSeoDemo00000001",
  "name": "Ops Automators - Error alert formatter",
  "nodes": [
    {
      "id": "manual",
      "name": "Run sample",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "parameters": {},
      "position": [
        0,
        260
      ]
    },
    {
      "id": "sample",
      "name": "Sample records",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "return [\n  {\n    \"execution\": {\n      \"id\": \"demo-104\",\n      \"url\": \"https://n8n.example.com/execution/demo-104\",\n      \"error\": {\n        \"name\": \"ValidationError\",\n        \"message\": \"Synthetic example only\"\n      },\n      \"lastNodeExecuted\": \"Validate invoice\"\n    },\n    \"workflow\": {\n      \"id\": \"demo-workflow\",\n      \"name\": \"Invoice validation demo\"\n    }\n  }\n].map(json => ({ json }));"
      },
      "position": [
        240,
        260
      ]
    },
    {
      "id": "logic",
      "name": "Format alert",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "return $input.all().map(({ json: input }) => {\n  const execution = input.execution || {};\n  const trigger = input.trigger || {};\n  const clean = (value, fallback) => String(value || fallback).replace(/[\\r\\n<>]/g, ' ').slice(0, 160);\n  const workflowName = clean(input.workflow?.name, 'Unnamed workflow');\n  const failedNode = clean(execution.lastNodeExecuted || trigger.error?.node?.name, 'Trigger or unknown node');\n  const executionId = execution.id ? clean(execution.id, '') : null;\n  let executionUrl = null;\n  if (typeof execution.url === 'string' && /^https?:\\/\\/[^\\s<>]+$/i.test(execution.url)) executionUrl = execution.url;\n  // Raw error messages/stacks may contain customer data or credentials. Keep them in n8n.\n  const lines = ['Workflow failed: ' + workflowName, 'Node: ' + failedNode];\n  if (executionId) lines.push('Execution: ' + executionId);\n  if (executionUrl) lines.push('Inspect: ' + executionUrl);\n  if (!executionId) lines.push('No saved execution ID; inspect the trigger and instance logs.');\n  return { json: { workflowName, failedNode, executionId, executionUrl, text: lines.join('\\n'), rawErrorIncluded: false } };\n});"
      },
      "position": [
        500,
        260
      ]
    },
    {
      "id": "instructions",
      "name": "Read before connecting systems",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "parameters": {
        "content": "## Ops Automators - Error alert formatter\n\nRun the manual sample to preview an alert. To use real failures, select this workflow as the Error workflow on a separate automatically triggered workflow. Add and configure a notification node after Format alert. This template formats output; it does not send an alert by itself.\n\nSetup: https://www.opsautomators.com/blog/n8n-workflow-templates\n\nSynthetic demo data. No credentials required. MIT licensed.",
        "height": 260,
        "width": 740
      },
      "position": [
        0,
        -70
      ]
    },
    {
      "id": "error",
      "name": "Error Trigger",
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "parameters": {},
      "position": [
        240,
        460
      ]
    }
  ],
  "connections": {
    "Run sample": {
      "main": [
        [
          {
            "node": "Sample records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sample records": {
      "main": [
        [
          {
            "node": "Format alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Format alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "tags": []
}
