See llms.txt for all machine-readable content.

Back to Templates

Monitor app errors and heartbeats with OpenAI triage and Gmail alerts

Quick overview

This workflow centralizes app error and heartbeat monitoring through a single webhook, uses OpenAI to triage new error types, stores state in n8n Data Tables, and sends Gmail alerts for urgent issues, repeated failures (escalation), back-online notifications, silence warnings, and periodic digests.

How it works

  1. Receives POST webhook events from apps and, depending on the run source, also performs a daily scheduled check, handles workflow-failure events, or runs a one-time setup.
  2. Validates and authenticates each incoming webhook using a per-app token (and optional allowed IPs), masks sensitive data, and classifies the payload as an error or heartbeat.
  3. For heartbeats, updates the app’s last heartbeat in the Watched apps Data Table, clears any “missing” flag, and emails a back-online message via Gmail if the app had previously gone silent.
  4. For errors, generates a normalized fingerprint, looks up the fingerprint in the Known errors Data Table, and uses OpenAI once per new/failed-to-triage fingerprint to produce a cause, first check, category, and urgency.
  5. Applies throttling and escalation rules to decide whether to email immediately, defer to the digest, or stay silent, then logs the event to the App events Data Table and updates the Known errors record.
  6. Every morning at 10:00, detects apps missing heartbeats past their threshold and sends one silence warning email per outage via Gmail, marking the warning timestamp in the Watched apps table.
  7. On digest days (daily or weekly), compiles recent events and top recurring errors (including saved AI notes) into an HTML digest and emails it via Gmail.

Setup

  1. Connect Gmail credentials for all Gmail email-sending steps and add an OpenAI credential for the OpenAI Chat Model (or set useAI to false in Settings to run without AI triage).
  2. Run the manual setup once to create the n8n Data Tables (Watched apps, App events, Known errors) and insert the example app row.
  3. Populate the Watched apps table with one row per app (app ID, token, recipient email, active=true, optional allowed_ips, heartbeat_max_hours, and throttle_hours).
  4. Update the Settings values (yourEmail, digestFrequency/digestWeekday, timezone, escalateAfter, defaultThrottleHours, and aiLanguage) to match your environment.
  5. Copy the production webhook URL for the webhook trigger and configure each app to POST error/heartbeat JSON with the x-guardian-token header.

Requirements

  • A Gmail account, an OpenAI API key (or set useAI to false), an n8n version with data tables, and apps that can make an HTTP request: a cron job with curl is enough.

Customization

  • Thresholds and allowed_ips are set per app in the Watched apps table (a nightly backup might use 36 hours, an hourly sync 3); digestFrequency, escalateAfter and aiLanguage are in Settings; swap Gmail for Slack or Telegram in the alert nodes, or OpenAI for another chat model.

Additional info

Tokens, passwords, API keys, bearer headers and email addresses are masked before anything is stored, emailed or sent to the AI. Once OpenAI has triaged an error, the verdict is reused for every repeat. There is deliberately no endpoint to register apps or change tokens: edit the table, so nobody can rewrite a token from outside. Emails are in Italian; their texts live in the Code nodes named on the canvas.