{
  "name": "Website uptime and broken-link monitor",
  "nodes": [
    {
      "id": "00000000-0000-4000-8000-000000000027",
      "name": "Every 15 minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        300
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 15
            }
          ]
        }
      }
    },
    {
      "id": "00000000-0000-4000-8000-000000000028",
      "name": "Site to check",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        280,
        300
      ],
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "siteUrl",
              "name": "siteUrl",
              "value": "https://example.com",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "00000000-0000-4000-8000-000000000029",
      "name": "Fetch homepage",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        560,
        300
      ],
      "parameters": {
        "method": "GET",
        "url": "={{ $json.siteUrl }}",
        "options": {
          "timeout": 15000,
          "response": {
            "response": {
              "neverError": true,
              "fullResponse": true
            }
          }
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 2000,
      "onError": "continueErrorOutput"
    },
    {
      "id": "00000000-0000-4000-8000-000000000030",
      "name": "Homepage status is an error",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        840,
        300
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "Homepage status is an error-condition",
              "leftValue": "={{ $json.statusCode }}",
              "rightValue": 400,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "00000000-0000-4000-8000-000000000031",
      "name": "Alert site down",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        1120,
        140
      ],
      "parameters": {
        "resource": "message",
        "operation": "post",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#ops-alerts"
        },
        "text": "=Site check failed for {{ $(\"Site to check\").item.json.siteUrl }} (status {{ $json.statusCode || \"no response\" }}).",
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "id": "SLACK_CREDENTIAL",
          "name": "Slack account"
        }
      }
    },
    {
      "id": "00000000-0000-4000-8000-000000000032",
      "name": "Extract same-site links",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1120,
        420
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const source = $(\"Site to check\").item.json.siteUrl || \"https://example.com\";\nconst html = String($json.body || $json.data || \"\");\nconst found = new Set();\nfor (const match of html.matchAll(/href\\s*=\\s*[\"']([^\"'#]+)[\"']/gi)) {\n  const raw = match[1].trim();\n  if (!raw || raw.startsWith(\"mailto:\") || raw.startsWith(\"tel:\") || raw.startsWith(\"javascript:\")) continue;\n  try {\n    const url = new URL(raw, source);\n    if (url.origin === new URL(source).origin) found.add(url.href.split(\"#\")[0]);\n  } catch (error) { continue; }\n}\nconst links = [...found].slice(0, 20).map((link) => ({ link }));\nreturn [{ json: { siteUrl: source, pageStatus: $json.statusCode ?? null, links } }];"
      }
    },
    {
      "id": "00000000-0000-4000-8000-000000000033",
      "name": "Cap at 20 links",
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        1400,
        420
      ],
      "parameters": {
        "maxItems": 20
      }
    },
    {
      "id": "00000000-0000-4000-8000-000000000034",
      "name": "One item per link",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        1680,
        420
      ],
      "parameters": {
        "fieldToSplitOut": "links",
        "options": {}
      }
    },
    {
      "id": "00000000-0000-4000-8000-000000000035",
      "name": "Check link",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1960,
        420
      ],
      "parameters": {
        "method": "GET",
        "url": "={{ $json.link }}",
        "options": {
          "timeout": 15000,
          "response": {
            "response": {
              "neverError": true,
              "fullResponse": true
            }
          }
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 2000,
      "onError": "continueErrorOutput"
    },
    {
      "id": "00000000-0000-4000-8000-000000000036",
      "name": "Link is broken",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        2240,
        420
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "Link is broken-condition",
              "leftValue": "={{ $json.statusCode }}",
              "rightValue": 400,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "00000000-0000-4000-8000-000000000037",
      "name": "Alert broken link",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        2520,
        280
      ],
      "parameters": {
        "resource": "message",
        "operation": "post",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#ops-alerts"
        },
        "text": "=Broken link {{ $('One item per link').item.json.link }} returned {{ $json.statusCode || \"no response\" }}.",
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "id": "SLACK_CREDENTIAL",
          "name": "Slack account"
        }
      }
    },
    {
      "id": "00000000-0000-4000-8000-000000000038",
      "name": "Leave healthy link alone",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2520,
        540
      ],
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "checked",
              "name": "checked",
              "value": "ok",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    }
  ],
  "pinData": {
    "Fetch homepage": [
      {
        "json": {
          "statusCode": 200,
          "body": "<html><body><a href=\"/pricing\">Pricing</a><a href=\"https://example.com/about\">About</a><a href=\"mailto:hi@example.com\">Email</a></body></html>"
        }
      }
    ]
  },
  "connections": {
    "Every 15 minutes": {
      "main": [
        [
          {
            "node": "Site to check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Site to check": {
      "main": [
        [
          {
            "node": "Fetch homepage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch homepage": {
      "main": [
        [
          {
            "node": "Homepage status is an error",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Alert site down",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Homepage status is an error": {
      "main": [
        [
          {
            "node": "Alert site down",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract same-site links",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract same-site links": {
      "main": [
        [
          {
            "node": "Cap at 20 links",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cap at 20 links": {
      "main": [
        [
          {
            "node": "One item per link",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "One item per link": {
      "main": [
        [
          {
            "node": "Check link",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check link": {
      "main": [
        [
          {
            "node": "Link is broken",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Alert broken link",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Link is broken": {
      "main": [
        [
          {
            "node": "Alert broken link",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Leave healthy link alone",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "timezone": "UTC",
    "saveDataErrorExecution": "all",
    "saveDataSuccessExecution": "all",
    "saveManualExecutions": true
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}
