{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "7b54581c-4dac-4d88-8ed4-9f1b36d8d3bc",
      "name": "Error Trigger",
      "type": "n8n-nodes-base.errorTrigger",
      "position": [
        -592,
        -432
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ddfff4da-ec7d-4eae-8cf8-0090e6e52c7c",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -368,
        -432
      ],
      "parameters": {
        "text": "=You are an expert error analysis assistant. Analyze the following n8n workflow error and extract all relevant information:\n\nError Message: {{ $json.error.message }}\nError Stack: {{ $json.error.stack }}\nNode Name: {{ $json.error.node?.name }}\nNode Type: {{ $json.error.node?.type }}\nWorkflow: {{ $('Error Trigger').item.json.workflow?.name }}\nExecution ID: {{ $('Error Trigger').item.json.execution?.id }}\n\nProvide a comprehensive analysis including:\n1. Root cause of the error\n2. Which node failed and why\n3. Potential solutions (at least 3)\n4. Impact assessment\n5. Prevention strategies\n6. Urgency level (Critical/High/Medium/Low)\n\nFormat your response in a clear, structured way.",
        "agent": "conversationalAgent",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "a3acf152-1625-4227-84b6-f7d4e9051f07",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -368,
        -208
      ],
      "parameters": {
        "options": {
          "maxTokens": 2000,
          "temperature": 0.3
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f0584236-49fa-4e25-8eb8-77a755978330",
      "name": "Format Data",
      "type": "n8n-nodes-base.set",
      "position": [
        0,
        -432
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6",
              "name": "errorMessage",
              "type": "string",
              "value": "={{ $('Error Trigger').item.json.error.message }}"
            },
            {
              "id": "b2c3d4e5-f6g7-h8i9-j0k1-l2m3n4o5p6q7",
              "name": "nodeName",
              "type": "string",
              "value": "={{ $('Error Trigger').item.json.error.node?.name || 'Unknown Node' }}"
            },
            {
              "id": "c3d4e5f6-g7h8-i9j0-k1l2-m3n4o5p6q7r8",
              "name": "nodeType",
              "type": "string",
              "value": "={{ $('Error Trigger').item.json.error.node?.type || 'Unknown Type' }}"
            },
            {
              "id": "d4e5f6g7-h8i9-j0k1-l2m3-n4o5p6q7r8s9",
              "name": "workflowName",
              "type": "string",
              "value": "={{ $('Error Trigger').item.json.workflow?.name || 'Unknown Workflow' }}"
            },
            {
              "id": "e5f6g7h8-i9j0-k1l2-m3n4-o5p6q7r8s9t0",
              "name": "executionId",
              "type": "string",
              "value": "={{ $('Error Trigger').item.json.execution?.id || 'N/A' }}"
            },
            {
              "id": "f6g7h8i9-j0k1-l2m3-n4o5-p6q7r8s9t0u1",
              "name": "timestamp",
              "type": "string",
              "value": "={{ $now.format('YYYY-MM-DD HH:mm:ss') }}"
            },
            {
              "id": "g7h8i9j0-k1l2-m3n4-o5p6-q7r8s9t0u1v2",
              "name": "errorStack",
              "type": "string",
              "value": "={{ $('Error Trigger').item.json.error.stack || 'No stack trace available' }}"
            },
            {
              "id": "h8i9j0k1-l2m3-n4o5-p6q7-r8s9t0u1v2w3",
              "name": "aiAnalysis",
              "type": "string",
              "value": "={{ $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c1657acd-5b52-4c47-8969-ed82637d30e9",
      "name": "Send Gmail Notification",
      "type": "n8n-nodes-base.gmail",
      "position": [
        272,
        -256
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=<!DOCTYPE html>\n<html>\n<head>\n    <style>\n        body {\n            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n            line-height: 1.6;\n            color: #333;\n            max-width: 800px;\n            margin: 0 auto;\n            background-color: #f5f5f5;\n        }\n        .container {\n            background-color: #ffffff;\n            border-radius: 8px;\n            box-shadow: 0 2px 4px rgba(0,0,0,0.1);\n            margin: 20px;\n            overflow: hidden;\n        }\n        .header {\n            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n            color: white;\n            padding: 30px;\n            text-align: center;\n        }\n        .header h1 {\n            margin: 0;\n            font-size: 24px;\n        }\n        .alert-icon {\n            font-size: 48px;\n            margin-bottom: 10px;\n        }\n        .content {\n            padding: 30px;\n        }\n        .error-box {\n            background-color: #fff5f5;\n            border-left: 4px solid #e53e3e;\n            padding: 15px;\n            margin: 20px 0;\n            border-radius: 4px;\n        }\n        .info-section {\n            margin: 25px 0;\n        }\n        .info-section h2 {\n            color: #667eea;\n            font-size: 18px;\n            margin-bottom: 10px;\n            border-bottom: 2px solid #667eea;\n            padding-bottom: 5px;\n        }\n        .info-row {\n            display: flex;\n            padding: 8px 0;\n            border-bottom: 1px solid #e2e8f0;\n        }\n        .info-label {\n            font-weight: bold;\n            min-width: 150px;\n            color: #4a5568;\n        }\n        .info-value {\n            color: #2d3748;\n            word-break: break-word;\n        }\n        .ai-analysis {\n            background-color: #f0f9ff;\n            border-left: 4px solid #3b82f6;\n            padding: 20px;\n            margin: 20px 0;\n            border-radius: 4px;\n            white-space: pre-wrap;\n        }\n        .stack-trace {\n            background-color: #1a202c;\n            color: #e2e8f0;\n            padding: 15px;\n            border-radius: 4px;\n            overflow-x: auto;\n            font-family: 'Courier New', monospace;\n            font-size: 12px;\n            margin: 15px 0;\n        }\n        .footer {\n            background-color: #f7fafc;\n            padding: 20px;\n            text-align: center;\n            color: #718096;\n            font-size: 14px;\n        }\n        .badge {\n            display: inline-block;\n            padding: 4px 12px;\n            border-radius: 12px;\n            font-size: 12px;\n            font-weight: bold;\n        }\n        .badge-error {\n            background-color: #fed7d7;\n            color: #c53030;\n        }\n    </style>\n</head>\n<body>\n    <div class=\"container\">\n        <div class=\"header\">\n            <div class=\"alert-icon\">\ud83d\udea8</div>\n            <h1>Workflow Error Alert</h1>\n            <p style=\"margin: 5px 0 0 0;\">{{ $json.timestamp }}</p>\n        </div>\n        \n        <div class=\"content\">\n            <div class=\"error-box\">\n                <h3 style=\"margin-top: 0; color: #c53030;\">\u26a0\ufe0f Error Message</h3>\n                <p style=\"margin: 0; font-size: 16px;\">{{ $json.errorMessage }}</p>\n            </div>\n\n            <div class=\"info-section\">\n                <h2>\ud83d\udccb Error Details</h2>\n                <div class=\"info-row\">\n                    <div class=\"info-label\">Workflow:</div>\n                    <div class=\"info-value\">{{ $json.workflowName }}</div>\n                </div>\n                <div class=\"info-row\">\n                    <div class=\"info-label\">Failed Node:</div>\n                    <div class=\"info-value\">{{ $json.nodeName }}</div>\n                </div>\n                <div class=\"info-row\">\n                    <div class=\"info-label\">Node Type:</div>\n                    <div class=\"info-value\"><span class=\"badge badge-error\">{{ $json.nodeType }}</span></div>\n                </div>\n                <div class=\"info-row\">\n                    <div class=\"info-label\">Execution ID:</div>\n                    <div class=\"info-value\">{{ $json.executionId }}</div>\n                </div>\n                <div class=\"info-row\">\n                    <div class=\"info-label\">Timestamp:</div>\n                    <div class=\"info-value\">{{ $json.timestamp }}</div>\n                </div>\n            </div>\n\n            <div class=\"info-section\">\n                <h2>\ud83e\udd16 AI Analysis & Recommendations</h2>\n                <div class=\"ai-analysis\">{{ $json.aiAnalysis }}</div>\n            </div>\n\n            <div class=\"info-section\">\n                <h2>\ud83d\udd0d Stack Trace</h2>\n                <div class=\"stack-trace\">{{ $json.errorStack }}</div>\n            </div>\n        </div>\n        \n        <div class=\"footer\">\n            <p><strong>n8n Workflow Error Monitoring System</strong></p>\n            <p>This is an automated notification from your n8n instance.</p>\n        </div>\n    </div>\n</body>\n</html>",
        "options": {},
        "subject": "=\ud83d\udea8 n8n Workflow Error: {{ $json.workflowName }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "62a142c1-0b10-4243-a7bc-29115ae69e73",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -736,
        -688
      ],
      "parameters": {
        "width": 304,
        "height": 416,
        "content": "## Triggers when workflows Fail\n\nMake sure you go to you production workflow > settings and select this workflow for Error Workflow\n\nNote- only production failures are caught by Error workflows"
      },
      "typeVersion": 1
    },
    {
      "id": "47896b05-5c0b-4c31-9aa4-a8179f3dfce1",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        -688
      ],
      "parameters": {
        "color": 4,
        "width": 304,
        "height": 608,
        "content": "## GPT Powered AI Analysis\n\n* Gathers information about failures\n* Work on all type of Failures"
      },
      "typeVersion": 1
    },
    {
      "id": "b03cabf7-4ab8-4585-bf1d-043cc3be4cf8",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        -688
      ],
      "parameters": {
        "color": 5,
        "width": 496,
        "height": 640,
        "content": "## Multi Notification System\n* Add as many as you need\n* Beautiful Email notifications with Error Breakdown"
      },
      "typeVersion": 1
    },
    {
      "id": "80f2bf42-c15f-426e-acf3-8c59a2ba7fee",
      "name": "Text Notification",
      "type": "n8n-nodes-base.telegram",
      "position": [
        256,
        -480
      ],
      "parameters": {
        "text": "={{ $json.aiAnalysis }}",
        "chatId": "<Your Chat ID>",
        "additionalFields": {}
      },
      "credentials": {},
      "typeVersion": 1.2
    },
    {
      "id": "de2ccee5-4140-4780-804d-37885130c84c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1264,
        -752
      ],
      "parameters": {
        "width": 496,
        "height": 944,
        "content": "## \u26a1 How This Error Monitoring Workflow Works\n\n### 1\ufe0f\u20e3 Set as Your Error Handler  \nGo to any production workflow \u2192 Settings \u2192 **Error Workflow** \u2192  \nSelect this workflow.  \n(Only production errors are captured.)\n\n### 2\ufe0f\u20e3 AI Error Diagnosis  \nThe AI Agent analyzes:  \n\u2022 Error message  \n\u2022 Stack trace  \n\u2022 Failed node (name + type)  \n\u2022 Workflow name  \n\u2022 Execution ID  \n\u2022 Timestamp  \nIt produces a clear root-cause + 3 recommended fixes.\n\n### 3\ufe0f\u20e3 Structured Output  \nThe Set node formats everything into a clean JSON payload for notifications.\n\n### 4\ufe0f\u20e3 Multi-Channel Alerts  \n\u2022 \ud83d\udce9 Gmail sends a full HTML error report  \n\u2022 \ud83d\udcf1 Telegram sends a quick AI summary  \nYou can add Slack, Discord, SMS, or ClickUp notifications easily.\n\n### 5\ufe0f\u20e3 Faster Fixes  \nEvery alert includes:  \nRoot cause \u2192 Impact \u2192 Solutions \u2192 Prevention \u2192 Urgency level.  \nPerfect for production reliability.\n\n---\n\n**Author: Sandeep Patharkar**  \n**Skool:** www.skool.com/aic-plus  \n**LinkedIn:** www.linkedin.com/in/sandeeppatharkar"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Format Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Data": {
      "main": [
        [
          {
            "node": "Send Gmail Notification",
            "type": "main",
            "index": 0
          },
          {
            "node": "Text Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Error Trigger": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}