{
  "name": "Telegram Server Uptime Alerting Bot",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [{ "field": "minutes", "minutesInterval": 5 }]
        }
      },
      "id": "tuat0001-0001-4000-8000-000000000001",
      "name": "Check Every 5 Minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "url": "={{ $env.MONITOR_URL }}",
        "options": {
          "timeout": 10000,
          "allowUnauthorizedCerts": false
        }
      },
      "id": "tuat0001-0002-4000-8000-000000000002",
      "name": "Ping Target Server",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [460, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "field1",
              "name": "statusCode",
              "value": "={{ $json.statusCode ?? 200 }}",
              "type": "number"
            },
            {
              "id": "field2",
              "name": "responseTime",
              "value": "={{ $json.responseTime ?? 0 }}",
              "type": "number"
            },
            {
              "id": "field3",
              "name": "checkedAt",
              "value": "={{ $now.toISO() }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "tuat0001-0003-4000-8000-000000000003",
      "name": "Parse Response",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [680, 300]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": false, "leftValue": "", "typeValidation": "strict" },
          "conditions": [
            {
              "id": "cond1",
              "leftValue": "={{ $json.statusCode }}",
              "rightValue": 200,
              "operator": { "type": "number", "operation": "notEquals" }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "tuat0001-0004-4000-8000-000000000004",
      "name": "Is Down?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [900, 300]
    },
    {
      "parameters": {
        "chatId": "={{ $env.TELEGRAM_ALERT_CHAT_ID }}",
        "text": "=🚨 *Server Down Alert*\\nURL: `{{ $env.MONITOR_URL }}`\\nStatus: {{ $json.statusCode }}\\nTime: {{ $json.checkedAt }}\\n\\nPlease investigate immediately!",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "id": "tuat0001-0005-4000-8000-000000000005",
      "name": "Send Down Alert",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [1120, 200]
    }
  ],
  "connections": {
    "Check Every 5 Minutes": {
      "main": [[{ "node": "Ping Target Server", "type": "main", "index": 0 }]]
    },
    "Ping Target Server": {
      "main": [[{ "node": "Parse Response", "type": "main", "index": 0 }]]
    },
    "Parse Response": {
      "main": [[{ "node": "Is Down?", "type": "main", "index": 0 }]]
    },
    "Is Down?": {
      "main": [
        [{ "node": "Send Down Alert", "type": "main", "index": 0 }],
        []
      ]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
