{
 "id": "r2notificationhu",
 "name": "AutomateRecipes \u2013 notification-hub",
 "nodes": [
  {
   "parameters": {
    "httpMethod": "POST",
    "path": "notify-hub",
    "responseMode": "responseNode",
    "options": {}
   },
   "name": "Hub webhook",
   "type": "n8n-nodes-base.webhook",
   "typeVersion": 2,
   "position": [
    0,
    0
   ],
   "id": "86a0a40b-2358-439f-889f-973bf454cc46",
   "webhookId": "f1fda911-e6e2-4fd4-8066-7bca914b54d2"
  },
  {
   "parameters": {
    "jsCode": "// EDIT THESE SETTINGS\nreturn [{json:{\n \"ntfyTopic\": \"CHANGE-ME-to-a-long-random-topic\",\n \"urgentWords\": [\n  \"down\",\n  \"failed\",\n  \"refund\",\n  \"chargeback\",\n  \"urgent\"\n ]\n}}];"
   },
   "name": "Config",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    240,
    0
   ],
   "id": "d3e06206-e3a3-4ede-9f06-3ffe66ac7d9d"
  },
  {
   "parameters": {
    "jsCode": "const w=$('Hub webhook').first().json,b=w.body||{},src=String((w.query||{}).source||b.source||'generic').toLowerCase(),c=$('Config').first().json;\nlet e;\nif(src==='payment'){const o=(b.data&&b.data.object)||b;e={title:`Payment: ${o.amount!=null?(o.amount/100).toFixed(2):'?'} ${(o.currency||'').toUpperCase()}`,message:`${b.type||'payment'} from ${o.customer_email||o.email||'unknown'}`,tags:'moneybag',priority:4}}\nelse if(src==='form'){e={title:`Form: ${b.name||b.email||'new submission'}`,message:`${b.email||''}\\n${b.message||''}`.trim(),tags:'memo',priority:3}}\nelse if(src==='uptime'){e={title:`Site ${b.status||'alert'}: ${b.url||''}`,message:b.detail||'',tags:'rotating_light',priority:5}}\nelse if(src==='order'){e={title:`Order #${b.order_id||'?'}: ${b.total||''}`,message:`${b.items||''} for ${b.customer||''}`,tags:'package',priority:3}}\nelse{e={title:b.title||`Event from ${src}`,message:b.message||JSON.stringify(b).slice(0,500),tags:'bell',priority:3}}\nconst txt=(e.title+' '+e.message).toLowerCase();if(c.urgentWords.some(x=>txt.includes(x)))e.priority=5;\ne.title=`[${src}] ${e.title}`.slice(0,200);e.message=(e.message||'-').slice(0,2000);return [{json:e}];"
   },
   "name": "Normalize event",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    480,
    0
   ],
   "id": "accf7199-dcd2-497a-9f18-44446ab4f458"
  },
  {
   "parameters": {
    "method": "POST",
    "url": "=https://ntfy.sh/{{ $('Config').first().json.ntfyTopic }}",
    "sendHeaders": true,
    "headerParameters": {
     "parameters": [
      {
       "name": "Title",
       "value": "={{ $json.title }}"
      },
      {
       "name": "Tags",
       "value": "={{ $json.tags || 'bell' }}"
      },
      {
       "name": "Priority",
       "value": "={{ $json.priority || 3 }}"
      }
     ]
    },
    "sendBody": true,
    "contentType": "raw",
    "rawContentType": "text/plain",
    "body": "={{ $json.message }}",
    "options": {}
   },
   "name": "Send ntfy alert",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "position": [
    720,
    0
   ],
   "id": "95066424-10e6-4525-b97c-2d737f5f6179"
  },
  {
   "parameters": {
    "respondWith": "json",
    "responseBody": "={{ JSON.stringify({ok:true,routed:$('Normalize event').first().json.title}) }}",
    "options": {}
   },
   "name": "Respond OK",
   "type": "n8n-nodes-base.respondToWebhook",
   "typeVersion": 1.1,
   "position": [
    960,
    0
   ],
   "id": "e2617b2e-7c7a-4131-ba3a-c68cb1640a60"
  }
 ],
 "connections": {
  "Hub webhook": {
   "main": [
    [
     {
      "node": "Config",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Config": {
   "main": [
    [
     {
      "node": "Normalize event",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Normalize event": {
   "main": [
    [
     {
      "node": "Send ntfy alert",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Send ntfy alert": {
   "main": [
    [
     {
      "node": "Respond OK",
      "type": "main",
      "index": 0
     }
    ]
   ]
  }
 },
 "settings": {
  "executionOrder": "v1"
 },
 "active": false,
 "pinData": {}
}