{ "id": "mobilityops-alert-receiver", "name": "Fleet Ops — Alert Receiver", "active": false, "nodes": [ { "parameters": {"httpMethod": "POST", "path": "mobilityops-alerts", "authentication": "headerAuth", "responseMode": "responseNode", "options": {}}, "id": "alert-webhook", "name": "Alertmanager webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [240, 300], "webhookId": "mobilityops-alerts", "credentials": {"httpHeaderAuth": {"name": "Fleet Ops Webhook Trigger Token"}} }, { "parameters": {"jsCode": "const body = $json.body ?? $json;\nif (!['firing', 'resolved'].includes(body.status) || !Array.isArray(body.alerts)) throw new Error('Invalid Alertmanager payload');\nconst alerts = body.alerts.slice(0, 25).map(a => ({name: String(a.labels?.alertname || 'Unknown alert').slice(0, 120), severity: String(a.labels?.severity || 'unknown').slice(0, 32), summary: String(a.annotations?.summary || '').slice(0, 500)}));\nconst esc = v => String(v).replace(/[&<>\\\"']/g, c => ({'&':'&','<':'<','>':'>','\\\"':'"',\"'\":'''}[c]));\nconst resolved = body.status === 'resolved';\nreturn [{json:{subject:`[Fleet Ops] ${resolved ? 'Hersteld' : 'Alert'} — ${alerts.length} signaal/signalen`,html:`

Fleet Ops ${resolved ? 'hersteld' : 'monitoringalert'}

Ontvangen ${esc($now.toISO())}

`}}];"}, "id": "validate-format", "name": "Validate and format", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [500, 300] }, { "parameters": {"respondWith": "json", "responseBody": "={{ { accepted: true } }}", "options": {}}, "id": "accept", "name": "Accept alert", "type": "n8n-nodes-base.respondToWebhook", "typeVersion": 1.4, "position": [740, 300] }, { "parameters": {"toRecipients": "jens@itworx.tech", "subject": "={{ $('Validate and format').item.json.subject }}", "bodyContent": "={{ $('Validate and format').item.json.html }}", "additionalFields": {"from": "n8n@itworx.tech", "bodyContentType": "html"}}, "id": "email", "name": "Send owner email", "type": "n8n-nodes-base.microsoftOutlook", "typeVersion": 2, "position": [980, 300], "credentials": {"microsoftOutlookOAuth2Api": {"id": "EDTj3sOsganaoDVL", "name": "M365 n8n Shared Mailbox"}}, "retryOnFail": true, "maxTries": 3, "waitBetweenTries": 1000 } ], "connections": { "Alertmanager webhook": {"main": [[{"node": "Validate and format", "type": "main", "index": 0}]]}, "Validate and format": {"main": [[{"node": "Accept alert", "type": "main", "index": 0}]]}, "Accept alert": {"main": [[{"node": "Send owner email", "type": "main", "index": 0}]]} }, "settings": {"executionOrder": "v1", "timezone": "Europe/Brussels", "errorWorkflow": "Xppn2rAEqUuyiCJF", "executionTimeout": 120, "saveDataSuccessExecution": "none", "saveDataErrorExecution": "all"}, "staticData": null, "meta": {"templateCredsSetupCompleted": false}, "pinData": {}, "tags": [] }