Uptime Kuma to Slack Alerts via n8n

{"time":1776378046139,"version":"2.28.2","blocks":[{"type":"header","data":{"text":"Uptime Kuma → n8n → Slack Alert Workflow","level":2}},{"type":"paragraph","data":{"text":"This n8n workflow receives status-change webhooks from Uptime Kuma and posts formatted alerts directly to Slack. When a monitored service goes down, your team gets an immediate red alert with full context. When it recovers, they get a clear green recovery notice — all without any manual polling or additional SaaS dependencies."}},{"type":"image","data":{"file":{"url":"/uploads/0934ff85d3a9347b5b0d.webp"},"caption":"n8n workflow diagram showing Uptime Kuma webhook to Slack alert automation","withBorder":false,"stretched":false,"withBackground":false}},{"type":"paragraph","data":{"text":"Workflow example (JSON) Download"}},{"type":"header","data":{"text":"How It Works","level":2}},{"type":"paragraph","data":{"text":"Uptime Kuma is a powerful, self-hosted monitoring tool that continuously checks the availability of your services — including websites, REST APIs, DNS records, TCP ports, and more. Whenever a monitored service changes state (from UP to DOWN, or from DOWN back to UP), Uptime Kuma fires a JSON payload to a configured webhook URL."}},{"type":"paragraph","data":{"text":"This n8n workflow listens on that webhook endpoint around the clock. When a payload arrives, the workflow parses the raw data into clean, structured fields, determines whether the event represents a DOWN or UP transition, and sends a color-coded Slack message containing the service name, target host, timestamp, and a human-readable summary of the event."}},{"type":"paragraph","data":{"text":"The end result is real-time Slack alerting for every service state change — with no manual polling, no missed incidents, and no third-party SaaS dependency beyond Slack itself. It’s a lightweight but highly effective addition to any self-hosted infrastructure monitoring stack."}},{"type":"header","data":{"text":"Workflow Flow","level":2}},{"type":"paragraph","data":{"text":"The workflow follows a simple, reliable branching pattern:"}},{"type":"code","data":{"code":"Webhook → Code (parse payload) → IF condition\n ├── True (DOWN) → Slack: red alert\n └── False (UP) → Slack: green recovery"}},{"type":"header","data":{"text":"Node Reference","level":2}},{"type":"header","data":{"text":"1. Webhook (Trigger)","level":3}},{"type":"paragraph","data":{"text":"This is the entry point of the workflow. It listens for incoming POST requests sent by Uptime Kuma whenever a monitor changes state."}},{"type":"list","data":{"style":"unordered","items":["Endpoint: POST /webhook/Anthemnetworkstatus","Expected payload: A JSON object containing body.heartbeat (status, ping, time, message) and body.monitor (name, hostname, URL, type)."]}},{"type":"paragraph","data":{"text":"Configure this webhook URL in Uptime Kuma under the notification settings for each monitor you want to receive alerts for."}},{"type":"header","data":{"text":"2. Code (JavaScript — Payload Parser)","level":3}},{"type":"paragraph","data":{"text":"This node takes the raw Uptime Kuma webhook payload and transforms it into clean, structured fields that downstream nodes can reliably consume."}},{"type":"paragraph","data":{"text":"Input fields read:"}},{"type":"list","data":{"style":"unordered","items":["body.heartbeat — contains status, ping, time, and msg","body.monitor — contains name, hostname, url, and type"]}},{"type":"paragraph","data":{"text":"Output fields created:"}},{"type":"list","data":{"style":"unordered","items":["isDown — boolean, set to true when heartbeat.status === 0 (Uptime Kuma uses 0 for DOWN and 1 for UP)","name — the monitor’s display name","hostnameOrURL — the monitor’s hostname or URL, whichever is available","time — the heartbeat timestamp, with a fallback to the current time if the field is missing","status — a human-friendly string: either \"Down\" or \"Up\"","msg — a human-readable summary of the state change event"]}},{"type":"paragraph","data":{"text":"The original heartbeat and monitor objects are also passed through for reference or future use."}},{"type":"header","data":{"text":"3. IF (Condition — Route by Status)","level":3}},{"type":"paragraph","data":{"text":"This node evaluates the isDown field and routes the execution into one of two branches:"}},{"type":"list","data":{"style":"unordered","items":["True (service is DOWN) → routes to the DOWN alert node","False (service is UP) → routes to the UP recovery alert node"]}},{"type":"paragraph","data":{"text":"The condition evaluates {{ $json.isDown }}."}},{"type":"header","data":{"text":"4. DOWN Alert (Slack — HTTP Request)","level":3}},{"type":"paragraph","data":{"text":"This node fires whenever a monitored service goes down. It sends a POST request to a Slack Incoming Webhook URL with a red-themed alert message designed to grab immediate attention."}},{"type":"list","data":{"style":"unordered","items":["Header: 🚨 Service is DOWN","Color: #e01e5a (red)","Fields included: Service name, Status, Target (hostname or URL), Time","Details: The raw heartbeat message and the formatted msg summary"]}},{"type":"header","data":{"text":"5. UP Alert (Slack — HTTP Request)","level":3}},{"type":"paragraph","data":{"text":"This node fires when a previously downed service recovers. It sends a POST request to the same Slack Incoming Webhook URL with a green-themed recovery message to confirm the service is healthy again."}},{"type":"list","data":{"style":"unordered","items":["Header: ✅ Service is UP","Color: #2eb886 (green)","Fields included: Service name, Status, Target (hostname or URL), Time","Details: The formatted msg summary"]}},{"type":"header","data":{"text":"Setup Notes","level":2}},{"type":"list","data":{"style":"unordered","items":["In Uptime Kuma, add a notification of type Webhook and point it to the n8n webhook URL shown above. Apply this notification to every monitor you want covered.","In n8n, update both Slack HTTP Request nodes with your actual Slack Incoming Webhook URL. You can use the same webhook URL for both DOWN and UP alerts, or route them to separate channels for better visibility.","Test the full workflow by temporarily pausing or toggling a monitor in Uptime Kuma. Confirm that both the DOWN and UP alerts appear correctly formatted in your Slack channel before relying on it in production."]}}]}