{
 "id": "realwebsiteuptim",
 "name": "AutomateRecipes \u2013 website-uptime-alert",
 "nodes": [
  {
   "parameters": {
    "rule": {
     "interval": [
      {
       "field": "minutes",
       "minutesInterval": 5
      }
     ]
    }
   },
   "name": "Schedule Trigger",
   "type": "n8n-nodes-base.scheduleTrigger",
   "typeVersion": 1.2,
   "position": [
    0,
    0
   ],
   "id": "0404ea1b-92a3-4ba7-9a0f-931198d14a4b"
  },
  {
   "parameters": {
    "jsCode": "// EDIT THESE SETTINGS\nreturn [{json:{\n \"ntfyTopic\": \"CHANGE-ME-to-a-long-random-topic\",\n \"urls\": [\n  \"https://automaterecipes.pages.dev/\",\n  \"https://automaterecipes.pages.dev/api/subscribe\"\n ],\n \"slowMs\": 3000\n}}];"
   },
   "name": "Config",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    240,
    0
   ],
   "id": "a99fbb19-a34f-496c-96b2-9772e4ed1fbb"
  },
  {
   "parameters": {
    "jsCode": "return $input.first().json.urls.map(url=>({json:{url,started:Date.now()}}));"
   },
   "name": "Split URLs",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    480,
    0
   ],
   "id": "d622c88a-3cb4-4020-9842-38b3b56bd8b4"
  },
  {
   "parameters": {
    "url": "={{ $json.url }}",
    "options": {
     "timeout": 15000,
     "response": {
      "response": {
       "fullResponse": true,
       "neverError": true
      }
     }
    }
   },
   "name": "Check URL",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "position": [
    720,
    0
   ],
   "id": "5dcdd1da-c4a6-4a0a-978e-e9a6d451b2e6"
  },
  {
   "parameters": {
    "jsCode": "const src=$('Split URLs').all(),cfg=$('Config').first().json;const bad=[];$input.all().forEach((r,i)=>{const s=r.json.statusCode,ms=Date.now()-src[i].json.started;if(!s||s>=400||ms>cfg.slowMs)bad.push(`${src[i].json.url} -> ${s||'no response'} (${ms} ms)`)});if(!bad.length)return [];return [{json:{title:'Website problem detected',tags:'warning',message:bad.join('\\n'),count:bad.length}}];"
   },
   "name": "Find problems",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    960,
    0
   ],
   "id": "8a7b6d0e-1109-408d-84bd-e4cd99a27336"
  },
  {
   "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' }}"
      }
     ]
    },
    "sendBody": true,
    "contentType": "raw",
    "rawContentType": "text/plain",
    "body": "={{ $json.message }}",
    "options": {}
   },
   "name": "Send ntfy alert",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "position": [
    1200,
    0
   ],
   "id": "ed6c0a08-51eb-4aba-9e35-c18568a395d5"
  },
  {
   "parameters": {},
   "name": "Run manually (test)",
   "type": "n8n-nodes-base.manualTrigger",
   "typeVersion": 1,
   "position": [
    0,
    200
   ],
   "id": "8a8ab5a9-e30d-4515-a30a-094f4c8052dc"
  }
 ],
 "connections": {
  "Schedule Trigger": {
   "main": [
    [
     {
      "node": "Config",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Config": {
   "main": [
    [
     {
      "node": "Split URLs",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Split URLs": {
   "main": [
    [
     {
      "node": "Check URL",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Check URL": {
   "main": [
    [
     {
      "node": "Find problems",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Find problems": {
   "main": [
    [
     {
      "node": "Send ntfy alert",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Run manually (test)": {
   "main": [
    [
     {
      "node": "Config",
      "type": "main",
      "index": 0
     }
    ]
   ]
  }
 },
 "settings": {
  "executionOrder": "v1"
 },
 "active": false,
 "pinData": {}
}