N
n8n Store
Workflow Market
Website Downtime Alert via LINE + Supabase Log

Website Downtime Alert via LINE + Supabase Log

by sayamol0 views

説明

Categories

🚀 DevOps🤖 AI & Machine Learning

Nodes Used

n8n-nodes-base.ifn8n-nodes-base.coden8n-nodes-base.coden8n-nodes-base.waitn8n-nodes-base.filtern8n-nodes-base.supabasen8n-nodes-base.stickyNoten8n-nodes-base.httpRequestn8n-nodes-base.uptimeRobotn8n-nodes-base.splitInBatches
Price無料
Views0
最終更新11/28/2025
workflow.json
{
  "nodes": [
    {
      "id": "6637ff1d-43ca-4545-b427-44568da387f9",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        200,
        1100
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f56c8d70-222d-436b-94c3-90f0018a3742",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -180,
        700
      ],
      "parameters": {
        "color": 3,
        "width": 2500,
        "height": 820,
        "content": "## Monitor Website Check when Down ##"
      },
      "typeVersion": 1
    },
    {
      "id": "675c17f6-f832-4a43-ac66-a5dea421bad8",
      "name": "Get Monitors",
      "type": "n8n-nodes-base.uptimeRobot",
      "position": [
        420,
        1100
      ],
      "parameters": {
        "filters": {},
        "resource": "monitor"
      },
      "credentials": {
        "uptimeRobotApi": {
          "id": "km4n54HVtydW8mDc",
          "name": "Uptime Robot account - Synlora"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2a73c7ca-0db5-4e1f-85f6-e9e18b7bde1b",
      "name": "LLM Message Format",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1080,
        1100
      ],
      "parameters": {
        "text": "={{ $json.text }} List all affected sites and add a short funny wish for the IT team.",
        "promptType": "define"
      },
      "typeVersion": 1.6
    },
    {
      "id": "332f202e-c87d-49d1-aa7a-942631547058",
      "name": "OpenAI GPT-4o Mini",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1180,
        1320
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "aYpST6RW43n0s7kw",
          "name": "OpenAi account - websayamol"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "64a391a8-4bdf-43ce-887f-af7a17e93904",
      "name": "Escape Newlines",
      "type": "n8n-nodes-base.code",
      "position": [
        1460,
        1200
      ],
      "parameters": {
        "jsCode": "const rawText = $input.first().json.text || '';\nconst cleanedText = rawText.replace(/\\n/g, '\\\\n');\nreturn [{ json: { text: cleanedText } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "171b91d8-b502-4a08-9056-ac075f215983",
      "name": "Send to LINE",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1680,
        1200
      ],
      "parameters": {
        "url": "https://api.line.me/v2/bot/message/push",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"to\": \"<YOUR_LINE_GROUP_ID>\",\n  \"messages\": [\n    {\n      \"type\": \"text\",\n      \"text\": \"{{ $json.text }}\"\n    }\n  ]\n} ",
        "sendBody": true,
        "jsonHeaders": "{\n  \"Authorization\": \"Bearer <YOUR_LINE_CHANNEL_TOKEN>\",\n  \"Content-Type\": \"application/json\"\n}",
        "sendHeaders": true,
        "specifyBody": "json",
        "specifyHeaders": "json"
      },
      "typeVersion": 4.2
    },
    {
      "id": "b8b4beb8-e2a9-45d7-88b1-9409519d070f",
      "name": "Filter Down Monitors",
      "type": "n8n-nodes-base.code",
      "position": [
        640,
        1200
      ],
      "parameters": {
        "jsCode": "const statusMap = { 0: \"⏸️ Paused\", 1: \"🕐 Not Checked Yet\", 2: \"✅ Up\", 8: \"⚠️ May Be Down\", 9: \"🔴 Down\" };\nconst now = new Date();\nconst options = { timeZone: 'Asia/Bangkok' };\nconst dateStr = now.toLocaleDateString('en-GB', options);\nconst timeStr = now.toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit', hour12: false, timeZone: 'Asia/Bangkok' });\nlet message = `Some websites seem to be 🔴 down or ⚠️ unstable.\\n📅 Date: ${dateStr} Time: ${timeStr} hrs\\n\\n`;\nlet server_down = 0;\nfor (const item of items) {\n  const id = item.json.id;\n  const name = item.json.friendly_name || item.json.name;\n  const statusCode = item.json.status;\n  const statusText = statusMap[statusCode] || statusCode;\n  if ((statusCode === 8 || statusCode === 9) && id !== 798534759) {\n    message += `• ${name} ➤ ${statusText}\\n`;\n    server_down = 1;\n  }\n}\nreturn [{ json: { server_down, text: message } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "2f2d9c4c-5d4e-483f-b800-f9cfe7c2e67c",
      "name": "If Down",
      "type": "n8n-nodes-base.if",
      "position": [
        860,
        1200
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.server_down.toString() }}",
              "rightValue": "1"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4498a432-f4b6-4beb-978a-58cc9fdbbd64",
      "name": "Wait 30 Min",
      "type": "n8n-nodes-base.wait",
      "position": [
        1900,
        1200
      ],
      "parameters": {
        "unit": "minutes",
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "c0b608e5-0da6-4e13-9334-35b0b6e9ab1a",
      "name": "Loop Over Monitors",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        640,
        960
      ],
      "parameters": {
        "options": {},
        "batchSize": "={{ $json.id }}"
      },
      "typeVersion": 3
    },
    {
      "id": "002eaa11-a871-4387-9cee-77c389ca43b4",
      "name": "Filter Status 9",
      "type": "n8n-nodes-base.filter",
      "position": [
        860,
        1000
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "9"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "a6b467c6-6f0e-41ac-8d15-7d70863f6499",
      "name": "Save to Supabase",
      "type": "n8n-nodes-base.supabase",
      "position": [
        860,
        800
      ],
      "parameters": {
        "tableId": "synlora_uptime_down",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "website",
              "fieldValue": "={{ $json.friendly_name }}"
            },
            {
              "fieldId": "statue",
              "fieldValue": "={{ $json.status }}"
            },
            {
              "fieldId": "uptime_id",
              "fieldValue": "={{ $json.id }}"
            }
          ]
        }
      },
      "credentials": {
        "supabaseApi": {
          "id": "SeVvA2bO6waWD6kW",
          "name": "Supabase account_DB-Synlora_n8n"
        }
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "If Down": {
      "main": [
        [
          {
            "node": "LLM Message Format",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Monitors": {
      "main": [
        [
          {
            "node": "Filter Down Monitors",
            "type": "main",
            "index": 0
          },
          {
            "node": "Loop Over Monitors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send to LINE": {
      "main": [
        [
          {
            "node": "Wait 30 Min",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Escape Newlines": {
      "main": [
        [
          {
            "node": "Send to LINE",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Status 9": {
      "main": [
        [
          {
            "node": "Loop Over Monitors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get Monitors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LLM Message Format": {
      "main": [
        [
          {
            "node": "Escape Newlines",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Monitors": {
      "main": [
        [
          {
            "node": "Save to Supabase",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Filter Status 9",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Down Monitors": {
      "main": [
        [
          {
            "node": "If Down",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

相关工作流