8
n8n 中文网amn8n.com

SLA监控与告警

高级

这是一个自动化工作流,包含 26 个节点。主要使用 If, Set, Cron, Slack, Zendesk 等节点。 使用Zendesk、Slack和Google Sheets的主动SLA监控与工单升级

前置要求
  • Slack Bot Token 或 Webhook URL
  • Google Sheets API 凭证

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "VFx1qpO7OYLJRTtq",
  "meta": {
    "instanceId": "8443f10082278c46aa5cf3acf8ff0f70061a2c58bce76efac814b16290845177",
    "templateCredsSetupCompleted": true
  },
  "name": "SLA 监控与告警",
  "tags": [],
  "nodes": [
    {
      "id": "5bbf4343-9879-42b5-b16e-c24c6c48d882",
      "name": "每小时触发",
      "type": "n8n-nodes-base.cron",
      "position": [
        -1904,
        608
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "61005911-1ea7-4e84-afe1-e394909fe306",
      "name": "⏰ SLA 监控概览",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2240,
        496
      ],
      "parameters": {
        "width": 280,
        "height": 300,
        "content": "⏰ 工作流开始"
      },
      "typeVersion": 1
    },
    {
      "id": "dbe9f15d-4e00-4018-ac5e-8ee35473c310",
      "name": "从 Zendesk 获取未解决工单",
      "type": "n8n-nodes-base.zendesk",
      "position": [
        -1680,
        608
      ],
      "parameters": {
        "options": {},
        "operation": "getAll",
        "returnAll": true
      },
      "credentials": {
        "zendeskApi": {
          "id": "BQ61OjTaFfNPQ1bK",
          "name": "Zendesk account-anuj"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c5eb8fbd-4837-437a-ba29-1b7e236d19dd",
      "name": "📥 Zendesk 获取",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1792,
        272
      ],
      "parameters": {
        "width": 280,
        "height": 300,
        "content": "📥 ZENDESK 数据检索"
      },
      "typeVersion": 1
    },
    {
      "id": "ff9333b9-b761-4ae7-8d1d-af38d44dc30e",
      "name": "筛选:仅未解决工单",
      "type": "n8n-nodes-base.if",
      "position": [
        -1456,
        608
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "open-filter",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "open"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b5a5e4bc-c62f-4093-bc6f-4ee998868cf8",
      "name": "🔍 筛选未解决",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1600,
        784
      ],
      "parameters": {
        "width": 280,
        "height": 280,
        "content": "🔍 未解决工单筛选器"
      },
      "typeVersion": 1
    },
    {
      "id": "988815d0-084f-411a-9fc7-5d3d4510030b",
      "name": "通知:无未解决工单",
      "type": "n8n-nodes-base.slack",
      "position": [
        -1232,
        704
      ],
      "webhookId": "7f4161c5-841c-4907-b1b1-d131922055ba",
      "parameters": {
        "text": "✅ No open tickets at this time",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09GNB90TED",
          "cachedResultName": "general-information"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "id": "rNqvWj9TfChPVRYY",
          "name": "Slack account vivek"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "d97ef397-098e-4310-a6aa-742990d45a54",
      "name": "✅ 清除告警",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1216,
        864
      ],
      "parameters": {
        "width": 280,
        "height": 280,
        "content": "✅ 无工单告警"
      },
      "typeVersion": 1
    },
    {
      "id": "6d07f0c0-c2f8-491f-b6b0-677d658ce8b4",
      "name": "计算 SLA 剩余时间",
      "type": "n8n-nodes-base.function",
      "position": [
        -1232,
        512
      ],
      "parameters": {
        "functionCode": "// Expects each ticket to include: created_at (ISO), sla_due (ISO), id, priority\nconst out = items.map(i => {\n  const t = i.json;\n  const now = new Date();\n  const created = new Date(t.created_at);\n  const due = new Date(t.sla_due);\n  const slaTotal = due - created; // ms\n  const timeRemainingMs = due - now;\n  const elapsed = slaTotal > 0 ? (1 - timeRemainingMs / slaTotal) : 1;\n  const percentElapsed = Math.round(elapsed * 100);\n  t.timeRemainingMinutes = Math.max(0, Math.round(timeRemainingMs / 60000));\n  t.percentElapsed = Math.min(100, Math.max(0, percentElapsed));\n  return { json: t };\n});\nreturn out;"
      },
      "typeVersion": 1
    },
    {
      "id": "c90f88a5-4da2-4ff0-a7a8-e3b06629d817",
      "name": "⏱️ SLA 计算",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1408,
        144
      ],
      "parameters": {
        "width": 280,
        "height": 340,
        "content": "⏱️ SLA 计算"
      },
      "typeVersion": 1
    },
    {
      "id": "6235fdfa-6f4f-4d05-a81f-3e5fce7b8f41",
      "name": "准备升级负载",
      "type": "n8n-nodes-base.set",
      "position": [
        -1008,
        512
      ],
      "parameters": {
        "values": {
          "number": [],
          "string": [
            {
              "name": "priority",
              "value": "High"
            },
            {
              "name": "note",
              "value": "Auto-prioritised due to SLA nearing breach"
            }
          ],
          "boolean": []
        },
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "0103cb4e-c5da-48e8-bd30-6d69b79a9347",
      "name": "🚨 升级",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1056,
        160
      ],
      "parameters": {
        "width": 280,
        "height": 300,
        "content": "🚨 升级负载"
      },
      "typeVersion": 1
    },
    {
      "id": "1ecaf93c-d3ac-454d-a39e-9ef12bf4c13c",
      "name": "🔴 90% 阈值",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -160
      ],
      "parameters": {
        "width": 280,
        "height": 280,
        "content": "🔴 关键阈值"
      },
      "typeVersion": 1
    },
    {
      "id": "cc40c04a-de71-41fa-9477-ab36fb883b60",
      "name": "🟡 75% 阈值",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        592
      ],
      "parameters": {
        "width": 280,
        "height": 280,
        "content": "🟡 警告阈值"
      },
      "typeVersion": 1
    },
    {
      "id": "f629e9ff-e0e5-4c28-a804-b4ff35b2452f",
      "name": "更新 Zendesk:警告优先级",
      "type": "n8n-nodes-base.zendesk",
      "position": [
        -784,
        512
      ],
      "parameters": {
        "id": "={{ $json.id }}",
        "operation": "update",
        "updateFields": {}
      },
      "credentials": {
        "zendeskApi": {
          "id": "BQ61OjTaFfNPQ1bK",
          "name": "Zendesk account-anuj"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e0571751-f696-4dce-9334-c496fc8e4ab7",
      "name": "🔄 Zendesk 更新",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        720
      ],
      "parameters": {
        "width": 280,
        "height": 280,
        "content": "🔄 ZENDESK 更新(75%+)"
      },
      "typeVersion": 1
    },
    {
      "id": "ac4530cf-eed4-4577-b32e-83b720039cac",
      "name": "更新 Zendesk:升级(90%+)",
      "type": "n8n-nodes-base.zendesk",
      "position": [
        -224,
        160
      ],
      "parameters": {
        "id": "={{ $json.id }}",
        "operation": "update",
        "updateFields": {}
      },
      "credentials": {
        "zendeskApi": {
          "id": "BQ61OjTaFfNPQ1bK",
          "name": "Zendesk account-anuj"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8334235e-e73e-4e1e-a869-05ea55dcd696",
      "name": "🚨 Zendesk 升级",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -192
      ],
      "parameters": {
        "width": 280,
        "height": 280,
        "content": "🚨 ZENDESK 更新(90%+)"
      },
      "typeVersion": 1
    },
    {
      "id": "67393b6d-e097-45fc-916b-c4367efdc5db",
      "name": "Slack 告警:SLA 警告",
      "type": "n8n-nodes-base.slack",
      "position": [
        -240,
        384
      ],
      "webhookId": "a1437f1a-4ff5-4698-9e07-fbb75902cc2e",
      "parameters": {
        "text": "={{ $json.message }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "C09GNB90TED",
          "cachedResultName": "general-information"
        },
        "otherOptions": {}
      },
      "typeVersion": 2.3
    },
    {
      "id": "2ff470b8-7e28-436d-b046-9d5eee814001",
      "name": "⚠️ Slack 告警",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        352
      ],
      "parameters": {
        "width": 280,
        "height": 300,
        "content": "⚠️ SLACK 警告告警"
      },
      "typeVersion": 1
    },
    {
      "id": "98d57cf4-7748-4c6a-a459-ba0c0bf7900f",
      "name": "📊 合规日志",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -544,
        1056
      ],
      "parameters": {
        "width": 280,
        "height": 300,
        "content": "📊 合规日志记录"
      },
      "typeVersion": 1
    },
    {
      "id": "e786ac7c-4d1b-45ce-ab4e-8103364357f3",
      "name": "记录到Google表格",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -144,
        896
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "ticket_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ticket_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "percent_elapsed",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "percent_elapsed",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "time_remaining_minutes",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "time_remaining_minutes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1GeP8mTYttDTnVqdNrr3omGbGxlV7qu-jihhcVbeKs6Q/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1GeP8mTYttDTnVqdNrr3omGbGxlV7qu-jihhcVbeKs6Q",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1GeP8mTYttDTnVqdNrr3omGbGxlV7qu-jihhcVbeKs6Q/edit?usp=drivesdk",
          "cachedResultName": "Stripe Data"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "s4dP1fNuVZ2gWvs3",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "c4f11e00-5027-4e1f-b544-f9d444fed3fd",
      "name": "📈 Sheets 日志记录",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        1072
      ],
      "parameters": {
        "width": 280,
        "height": 300,
        "content": "📈 GOOGLE SHEETS 日志记录"
      },
      "typeVersion": 1
    },
    {
      "id": "6e465ec5-cccd-42a1-8a99-b70a1a9f5737",
      "name": "如果 ≥ 90%(升级)1",
      "type": "n8n-nodes-base.if",
      "position": [
        -560,
        176
      ],
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$json[\"percentElapsed\"]}}",
              "value2": 90,
              "operation": "largerEqual"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0ff34295-27aa-4411-8f06-9d1c5c33ec84",
      "name": "如果 ≥ 75%(警告)1",
      "type": "n8n-nodes-base.if",
      "position": [
        -560,
        512
      ],
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$json[\"percentElapsed\"]}}",
              "value2": 75,
              "operation": "largerEqual"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "670ef417-71e2-4683-b107-c6e14bc7001e",
      "name": "准备合规日志1",
      "type": "n8n-nodes-base.function",
      "position": [
        -480,
        896
      ],
      "parameters": {
        "functionCode": "// Append a simple compliance log object to output for later storage or aggregation\nreturn items.map(i => ({ json: { id: i.json.id, percentElapsed: i.json.percentElapsed, timeRemainingMinutes: i.json.timeRemainingMinutes, timestamp: new Date().toISOString() } }));"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1782ce88-b776-4180-a138-a1b6c94aa5b5",
  "connections": {
    "If ≥ 75% (Warn)1": {
      "main": [
        [
          {
            "node": "Alert Slack: SLA Warning",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger Every Hour": {
      "main": [
        [
          {
            "node": "Fetch Open Tickets from Zendesk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If ≥ 90% (Escalate)1": {
      "main": [
        [
          {
            "node": "Update Zendesk: Escalate (90%+)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Compliance Log1": {
      "main": [
        [
          {
            "node": "Log to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter: Open Tickets Only": {
      "main": [
        [
          {
            "node": "Calculate SLA Time Remaining",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notify: No Open Tickets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Escalation Payload": {
      "main": [
        [
          {
            "node": "Update Zendesk: Warning Priority",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate SLA Time Remaining": {
      "main": [
        [
          {
            "node": "Prepare Escalation Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Open Tickets from Zendesk": {
      "main": [
        [
          {
            "node": "Filter: Open Tickets Only",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Zendesk: Warning Priority": {
      "main": [
        [
          {
            "node": "If ≥ 90% (Escalate)1",
            "type": "main",
            "index": 0
          },
          {
            "node": "If ≥ 75% (Warn)1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Prepare Compliance Log1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量26
分类-
节点类型8
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Rahul Joshi

Rahul Joshi

@rahul08

Rahul Joshi is a seasoned technology leader specializing in the n8n automation tool and AI-driven workflow automation. With deep expertise in building open-source workflow automation and self-hosted automation platforms, he helps organizations eliminate manual processes through intelligent n8n ai agent automation solutions.

外部链接
在 n8n.io 查看

分享此工作流