{
  "name": "Lunexo – Website Health Monitor",
  "nodes": [
    {
      "parameters": {
        "content": "## Website Health Monitor\n\n**What it does:** Checks multiple URLs every 15 minutes and sends Telegram + email alerts when a site is down (non-2xx response).\n\n**Setup (~10 min):**\n1. Add your SMTP credentials\n2. Add your Telegram Bot API credentials\n3. Replace `YOUR_SITE_1/2/3` URLs in the Define Sites node\n4. Replace `YOUR_ADMIN_EMAIL` with your inbox\n5. Replace `YOUR_TELEGRAM_CHAT_ID` with your chat ID\n6. Activate the workflow\n\n**Variables to change:**\n- `YOUR_SITE_1` / `YOUR_SITE_2` / `YOUR_SITE_3` — URLs to monitor\n- `YOUR_ADMIN_EMAIL` — alert recipient\n- `YOUR_TELEGRAM_CHAT_ID` — Telegram chat ID",
        "height": 350,
        "width": 350,
        "color": 5
      },
      "id": "d6a20001-c3d4-5e6f-b7a8-600000000001",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [40, 80]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 15
            }
          ]
        },
        "options": {}
      },
      "id": "d6a20001-c3d4-5e6f-b7a8-600000000002",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [240, 300]
    },
    {
      "parameters": {
        "jsCode": "const sites = [\n  { url: 'YOUR_SITE_1', name: 'Main Site' },\n  { url: 'YOUR_SITE_2', name: 'API' },\n  { url: 'YOUR_SITE_3', name: 'Dashboard' }\n];\n\nreturn sites.map(site => ({ json: site }));"
      },
      "id": "d6a20001-c3d4-5e6f-b7a8-600000000003",
      "name": "Define Sites",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "d6a20001-c3d4-5e6f-b7a8-600000000004",
      "name": "Split In Batches",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [680, 300]
    },
    {
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {
          "timeout": 10000,
          "response": {
            "response": {
              "neverError": true,
              "fullResponse": true
            }
          }
        }
      },
      "id": "d6a20001-c3d4-5e6f-b7a8-600000000005",
      "name": "Check URL",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [900, 300]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "d6a20001-cond-0001",
              "leftValue": "={{ $json.statusCode }}",
              "rightValue": 200,
              "operator": {
                "type": "number",
                "operation": "lt"
              }
            },
            {
              "id": "d6a20001-cond-0002",
              "leftValue": "={{ $json.statusCode }}",
              "rightValue": 399,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "or"
        }
      },
      "id": "d6a20001-c3d4-5e6f-b7a8-600000000006",
      "name": "IF Site Down",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [1120, 300]
    },
    {
      "parameters": {
        "jsCode": "const item = $input.first().json;\nconst siteName = item.name || item.url || 'Unknown';\nconst statusCode = item.statusCode || 'No response';\nconst url = item.url || 'N/A';\nconst timestamp = new Date().toISOString();\n\nconst alertHtml = `<div style=\"font-family:Arial,sans-serif;max-width:600px;margin:0 auto;padding:20px;\">`\n  + `<h2 style=\"color:#e53e3e;\">⚠️ Site Down Alert</h2>`\n  + `<table style=\"width:100%;border-collapse:collapse;margin:16px 0;\">`\n  + `<tr><td style=\"padding:8px;border-bottom:1px solid #eee;font-weight:bold;\">Site</td><td style=\"padding:8px;border-bottom:1px solid #eee;\">${siteName}</td></tr>`\n  + `<tr><td style=\"padding:8px;border-bottom:1px solid #eee;font-weight:bold;\">URL</td><td style=\"padding:8px;border-bottom:1px solid #eee;\">${url}</td></tr>`\n  + `<tr><td style=\"padding:8px;border-bottom:1px solid #eee;font-weight:bold;\">Status Code</td><td style=\"padding:8px;border-bottom:1px solid #eee;color:red;\">${statusCode}</td></tr>`\n  + `<tr><td style=\"padding:8px;font-weight:bold;\">Time</td><td style=\"padding:8px;\">${timestamp}</td></tr>`\n  + `</table>`\n  + `<p style=\"color:#888;font-size:12px;\">— Lunexo Website Health Monitor</p>`\n  + `</div>`;\n\nconst telegramAlert = `🚨 SITE DOWN\\n\\n📛 ${siteName}\\n🔗 ${url}\\n❌ Status: ${statusCode}\\n🕐 ${timestamp}`;\n\nreturn [{ json: { siteName, url, statusCode, timestamp, alertHtml, telegramAlert } }];"
      },
      "id": "d6a20001-c3d4-5e6f-b7a8-600000000007",
      "name": "Format Alert",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1340, 200]
    },
    {
      "parameters": {
        "chatId": "YOUR_TELEGRAM_CHAT_ID",
        "text": "={{ $json.telegramAlert }}",
        "additionalFields": {}
      },
      "id": "d6a20001-c3d4-5e6f-b7a8-600000000008",
      "name": "Send Telegram Alert",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [1560, 200],
      "credentials": {
        "telegramApi": {
          "id": "CHANGE_ME",
          "name": "Your Telegram Bot"
        }
      }
    },
    {
      "parameters": {
        "fromEmail": "noreply@yourdomain.com",
        "toEmail": "YOUR_ADMIN_EMAIL",
        "subject": "=⚠️ Site Down: {{ $json.siteName }} ({{ $json.statusCode }})",
        "emailType": "html",
        "html": "={{ $json.alertHtml }}",
        "options": {}
      },
      "id": "d6a20001-c3d4-5e6f-b7a8-600000000009",
      "name": "Send Email Alert",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [1780, 200],
      "credentials": {
        "smtp": {
          "id": "CHANGE_ME",
          "name": "Your SMTP Account"
        }
      }
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Define Sites",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Define Sites": {
      "main": [
        [
          {
            "node": "Split In Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split In Batches": {
      "main": [
        [
          {
            "node": "Check URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check URL": {
      "main": [
        [
          {
            "node": "IF Site Down",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Site Down": {
      "main": [
        [
          {
            "node": "Format Alert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Split In Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Alert": {
      "main": [
        [
          {
            "node": "Send Telegram Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Telegram Alert": {
      "main": [
        [
          {
            "node": "Send Email Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email Alert": {
      "main": [
        [
          {
            "node": "Split In Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d6a20001-c3d4-5e6f-b7a8-600000000099",
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "lunexo"
  },
  "pinData": {},
  "staticData": null,
  "tags": [
    { "name": "Lunexo" },
    { "name": "Monitoring" },
    { "name": "Uptime" }
  ]
}