{
  "name": "Error Workflow",
  "nodes": [
    {
      "parameters": {
        "sendTo": "n8n-automation@example.com",
        "subject": "=Workflow {{ $json.workflow.name }} Failed!",
        "message": "=<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Workflow Error Notification</title>\n    <style>\n        body {\n            font-family: Arial, sans-serif;\n            background-color: #f4f4f4;\n            color: #333;\n            margin: 0;\n            padding: 0;\n        }\n\n        .container {\n            max-width: 600px;\n            margin: 20px auto;\n            background-color: #ffffff;\n            border-radius: 8px;\n            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);\n            overflow: hidden;\n            border: 1px solid #ddd;\n        }\n\n        .header {\n            background-color: #d32f2f;\n            color: white;\n            text-align: center;\n            padding: 10px 20px;\n            font-size: 20px;\n        }\n\n        .content {\n            padding: 20px;\n            line-height: 1.6;\n        }\n\n        .label {\n            font-weight: bold;\n            color: #555;\n        }\n\n        .important {\n            color: #d32f2f;\n            font-weight: bold;\n        }\n\n        .section-title {\n            color: #d32f2f;\n            border-bottom: 1px solid #ddd;\n            padding-bottom: 5px;\n        }\n\n        .code-block {\n            background-color: #f9f9f9;\n            border-left: 4px solid #d32f2f;\n            padding: 10px;\n            font-family: 'Courier New', monospace;\n            color: #333;\n            white-space: pre-wrap;\n            word-wrap: break-word;\n            margin-top: 10px;\n        }\n\n        .footer {\n            background-color: #eaeaea;\n            text-align: center;\n            padding: 10px;\n            font-size: 12px;\n            color: #777;\n        }\n    </style>\n</head>\n\n<body>\n    <div class=\"container\">\n        <div class=\"header\">\n            Workflow Error Notification\n        </div>\n        <div class=\"content\">\n            <p><span class=\"label\">Workflow:</span> <span class=\"important\">{{ $json.workflow.name }}</span></p>\n            <p><span class=\"label\">Date & Time:</span> {{ $now }}</p>\n            <p><span class=\"label\">Last Node Executed:</span> {{ $json.execution.lastNodeExecuted }}</p>\n\n            <h3 class=\"section-title\">Error Details</h3>\n            <div class=\"code-block\">\n                {{ $json.execution.error.message }}\n            </div>\n\n            <h3 class=\"section-title\">Error Stack</h3>\n            <div class=\"code-block\">\n                {{ $json.execution.error.stack }}\n            </div>\n        </div>\n        <div class=\"footer\">\n            This is an automated message from your workflow monitoring system. Please do not reply.\n        </div>\n    </div>\n</body>\n\n</html>\n",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        260,
        0
      ],
      "id": "bdab2e8a-b76c-4fdb-857a-f3a04cf4fb8e",
      "name": "Gmail",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/1AI88eTPYIKIjdKkmtBWO7DYODbnZIqaijGitJKmhkxI/edit?gid=0#gid=0",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "log",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1AI88eTPYIKIjdKkmtBWO7DYODbnZIqaijGitJKmhkxI/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Workflow": "={{ $json.workflow.name }}",
            "Timestamp": "={{ $now.format('yyyy-MM-dd hh:mma') }}",
            "URL": "={{ $json.execution.url }}",
            "Error Message": "={{ $json.execution.error.message }}",
            "Node": "={{ $json.execution.error.node.name  }} ",
            "Execution ID": "={{ $json.execution.id }}"
          },
          "matchingColumns": [
            "Timestamp"
          ],
          "schema": [
            {
              "id": "Workflow",
              "displayName": "Workflow",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "URL",
              "displayName": "URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Timestamp",
              "displayName": "Timestamp",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Node",
              "displayName": "Node",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Error Message",
              "displayName": "Error Message",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Execution ID",
              "displayName": "Execution ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        260,
        200
      ],
      "id": "61163476-816f-45a0-8f76-cd7a27249877",
      "name": "Google Sheets",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.line.me/v2/bot/message/push",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"to\": \"{{ $json.line_uid }}\",\n  \"messages\": [\n    {\n      \"type\": \"text\",\n      \"text\": \"{{ $json.message }}\"\n    }\n  ]\n}",
        "options": {}
      },
      "id": "c819d979-aa96-4f43-b171-0f0cd423cb2e",
      "name": "Line : Push Message",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        480,
        420
      ],
      "typeVersion": 4.2,
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6278f340-6287-4e89-b774-f6c584954d5b",
              "name": "line_uid",
              "type": "string",
              "value": "Uee67d82636f96a3c2d3d42a13f33aef2"
            },
            {
              "id": "9f85ac53-9907-448d-afa4-c54b41ddf868",
              "name": "message",
              "value": "=\u5de5\u4f5c\u6d41\u7a0b\u932f\u8aa4-{{ $('Error Trigger').item.json.workflow.name }}\\n{{ $('Error Trigger').item.json.execution.error.node.name }}\u767c\u751f\u932f\u8aa4\u65bc{{ $now.format('yyyy-MM-dd hh:mma') }}\u3002\\n\\n\u932f\u8aa4\u8a0a\u606f\u70ba\uff1a{{ $('Error Trigger').item.json.execution.error.message }}\\n\u5728\u9019\u88e1\u67e5\u770b\u6b64\u57f7\u884c\u8a18\u9304\uff1a{{ $('Error Trigger').item.json.execution.url }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "50565887-e372-4bee-9dc3-7fd51154735c",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        260,
        420
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "content": "## \u932f\u8aa4\u8655\u7406\u5de5\u4f5c\u6d41\uff0c\u89f8\u767c\u4e09\u7a2e\u901a\u77e5\u65b9\u5f0f\n\n1. Email\n2. Google sheet\n3. Line \n\n",
        "height": 780,
        "width": 890,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -60,
        -160
      ],
      "id": "ca8b1b1e-cecf-4a21-af21-a9587a0ec984",
      "name": "Sticky Note2"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "8f142f86-a996-42e4-981e-0d74e9b344d3",
      "name": "Error Trigger"
    },
    {
      "parameters": {
        "content": "## \u5feb\u901f\u9078\u64c7\u6307\u5357\n\n- \u5982\u679c\u4f60\u5e0c\u671b\u99ac\u4e0a\u77e5\u9053\u932f\u8aa4\uff0c\u4e14\u80fd\u884c\u52d5\u5feb\u901f\u53cd\u61c9 \u2794 \u7528 LINE\u3002\n- \u5982\u679c\u4f60\u9700\u8981\u6709\u500b\u6b63\u5f0f\u7d00\u9304\uff0c\u4f46\u4e0d\u6025\u8457\u7b2c\u4e00\u6642\u9593\u56de\u61c9 \u2794 \u7528 Email\u3002\n- \u5982\u679c\u4f60\u8981\u9577\u671f\u7d71\u8a08\u8207\u5206\u6790\u932f\u8aa4\u8da8\u52e2 \u2794 \u7528 Google Sheets\u3002\n\n\nAlex \u788e\u788e\u5ff5\uff1a\u6211\u500b\u4eba\u559c\u6b61\u7528 Google Sheets \u7d00\u9304\uff0c\u7528 Email \u4f86\u901a\u77e5\u6211\uff01\n\nLine \u76f8\u95dc\u8a2d\u5b9a\uff0c\u53ef\u4ee5\u53c3\u8003\uff1ahttps://youtu.be/HJKDHJ5x1F0",
        "height": 780,
        "width": 450
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -520,
        -160
      ],
      "id": "599f81f9-e7dc-45f1-aaf3-f749ec7ffada",
      "name": "Sticky Note"
    }
  ],
  "connections": {
    "Google Sheets": {
      "main": [
        []
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Line : Push Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          },
          {
            "node": "Gmail",
            "type": "main",
            "index": 0
          },
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "timezone": "Asia/Taipei",
    "callerPolicy": "workflowsFromSameOwner",
    "executionTimeout": 300
  },
  "versionId": "e9601d58-ef1f-4ddd-bd88-d6a334423ec2",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "0fS0IZwY5xyvbexo",
  "tags": [
    {
      "createdAt": "2025-02-20T10:56:36.149Z",
      "updatedAt": "2025-02-20T10:56:36.149Z",
      "id": "qc8YQ51rp9Uf0sOf",
      "name": "prd"
    },
    {
      "createdAt": "2025-03-17T08:20:06.861Z",
      "updatedAt": "2025-03-17T08:20:06.861Z",
      "id": "pvRmfUcHdkTEgrk9",
      "name": "yt"
    }
  ]
}