{
  "name": "MOMO 系統健康監控",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 5
            }
          ]
        }
      },
      "id": "schedule-trigger",
      "name": "每 5 分鐘執行",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.1,
      "position": [0, 0]
    },
    {
      "parameters": {
        "url": "http://192.168.0.110:5001/health",
        "options": {
          "timeout": 10000
        }
      },
      "id": "http-request",
      "name": "檢查 Health API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [220, 0]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.status }}",
              "value2": "healthy"
            }
          ]
        }
      },
      "id": "if-healthy",
      "name": "狀態是否正常?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [440, 0]
    },
    {
      "parameters": {
        "chatId": "5619078117",
        "text": "=🔴 **MOMO 系統異常告警**\n\n⏰ 時間: {{ $now.format('yyyy-MM-dd HH:mm:ss') }}\n📍 狀態: {{ $json.status || '無回應' }}\n🗄️ 資料庫: {{ $json.database || '未知' }}\n\n請立即檢查系統！",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "id": "telegram-alert",
      "name": "發送 Telegram 告警",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.1,
      "position": [660, 100],
      "credentials": {
        "telegramApi": {
          "id": "telegram-cred",
          "name": "MOMO Telegram Bot"
        }
      }
    },
    {
      "parameters": {},
      "id": "no-op",
      "name": "系統正常 (不做任何事)",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [660, -100]
    }
  ],
  "connections": {
    "每 5 分鐘執行": {
      "main": [
        [
          {
            "node": "檢查 Health API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "檢查 Health API": {
      "main": [
        [
          {
            "node": "狀態是否正常?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "狀態是否正常?": {
      "main": [
        [
          {
            "node": "系統正常 (不做任何事)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "發送 Telegram 告警",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    {
      "name": "監控"
    }
  ],
  "triggerCount": 0
}
