{
  "nodes": [
    {
      "id": "00140d4e-0975-4835-91f2-c4890bb373b2",
      "name": "When clicking \u2018Test workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1900,
        1580
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "ad4ef337-09a6-4031-882a-ec5d40ef9ae4",
      "name": "Convert to File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -900,
        780
      ],
      "parameters": {
        "options": {},
        "operation": "toJson",
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1.1
    },
    {
      "id": "194bd486-b24d-4169-b447-ff5878c92bdb",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -1200,
        1220
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "data"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "a781fb7f-1ab6-4a8c-a1ab-c301dbd465e5",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -2040,
        860
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 15
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8ee8b36c-da98-40b7-850f-aa8957734f6b",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2060,
        680
      ],
      "parameters": {
        "width": 760,
        "content": "### Receive an alert when new breaches are added to haveibeenpwned.com\n\n*\ud83d\udcdc Review the [changelog](https://relezy.com/changelog/xqus-haveibeenpwnedcom-breaches).*\n\nThis workflow demonstrates how we can receive alerts when new breaches are added to haveibeenpwned.com.\nIt also demonstrates a simple method for caching data between executions."
      },
      "typeVersion": 1
    },
    {
      "id": "b24ef1a2-f8d2-4d0b-9df2-58d657d80672",
      "name": "Request breaches",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1780,
        860
      ],
      "parameters": {
        "url": "https://haveibeenpwned.com/api/v3/latestbreach",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "b7e516d2-bb44-4d1a-8381-5ace8f13e793",
      "name": "Read last breach",
      "type": "n8n-nodes-base.readWriteFile",
      "notes": "we alerted about.",
      "position": [
        -1560,
        1040
      ],
      "parameters": {
        "options": {},
        "fileSelector": "./cache.json"
      },
      "notesInFlow": true,
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "367732d5-357a-4b96-ab78-f2101bc6519f",
      "name": "Get JSON from file",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -1380,
        1120
      ],
      "parameters": {
        "options": {},
        "operation": "fromJson"
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "cfa77370-ae6c-48b6-b43a-e7ce2223bb48",
      "name": "Check for content",
      "type": "n8n-nodes-base.if",
      "position": [
        -1020,
        1220
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "6bf6a0bd-e9b3-4fde-a9cc-08f4d0e94fd6",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.lastItem }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "9219d25d-72a9-4cb7-9ed3-889a6a022fef",
      "name": "Set to none",
      "type": "n8n-nodes-base.set",
      "notes": "File was empty.",
      "position": [
        -840,
        1280
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "47736e3f-0961-4b73-b4d5-207792640e87",
              "name": "lastItem",
              "type": "string",
              "value": "none"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 3.4
    },
    {
      "id": "6b99d638-0eb5-4bbe-b7c7-731d5e5efc92",
      "name": "If - check for new",
      "type": "n8n-nodes-base.if",
      "position": [
        -1380,
        860
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "badd0a56-081f-49e2-92f4-7711f1cd9289",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.lastItem }}",
              "rightValue": "={{ $json.Name }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "19c9a9ec-3f79-4de3-bd12-8887c35577d3",
      "name": "Set breach name",
      "type": "n8n-nodes-base.set",
      "position": [
        -1100,
        780
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d0714936-9956-4af8-93f9-3c44ef7beb09",
              "name": "lastItem",
              "type": "string",
              "value": "={{ $json.Name }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fd800b7d-6b28-4764-8d24-02e1f573f579",
      "name": "Write breach name to file",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        -720,
        780
      ],
      "parameters": {
        "options": {},
        "fileName": "./cache.json",
        "operation": "write"
      },
      "typeVersion": 1
    },
    {
      "id": "981fe638-de7f-4866-a195-ee2bdbcfbf4d",
      "name": "New breach",
      "type": "n8n-nodes-base.noOp",
      "notes": "Send alert",
      "position": [
        -1100,
        520
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "0266e90f-46cd-490f-8897-bc7b9080de40",
      "name": "Old breach",
      "type": "n8n-nodes-base.noOp",
      "notes": "already alerted.",
      "position": [
        -1100,
        1040
      ],
      "parameters": {},
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "95a4c08a-dfb6-40b4-88ef-bfb24f862495",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1140,
        700
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 240,
        "content": "### Save the name of the breach\nWe will check it the next time the workflow runs to see if we have a new breach."
      },
      "typeVersion": 1
    },
    {
      "id": "79eaf6a2-2120-4525-b597-ca08ac4d103c",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1140,
        960
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 240,
        "content": "### This breach has been seen before\nIf we end up here it means that the latest breach has been seen before."
      },
      "typeVersion": 1
    },
    {
      "id": "bf48f803-2355-4d7f-abb7-6ddcbcf81f8d",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1140,
        440
      ],
      "parameters": {
        "color": 3,
        "width": 640,
        "height": 240,
        "content": "### This is a new breach - send alert\nIf we end up here it means that the latest breach is new. Time to send some alerts to Slack, or Discord or something."
      },
      "typeVersion": 1
    },
    {
      "id": "6a805df1-3a30-447f-86c6-2cdef050e044",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1760,
        1500
      ],
      "parameters": {
        "color": 7,
        "width": 600,
        "height": 260,
        "content": "### Clean up the cache\nDelete the `./cache.json` file. This will make sure the alert is triggered on the next run."
      },
      "typeVersion": 1
    },
    {
      "id": "9734f72b-eaf6-4a8e-bdcb-59920ac0ac04",
      "name": "Set empty json",
      "type": "n8n-nodes-base.set",
      "position": [
        -1720,
        1580
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "69f35659-fd32-4fa7-969e-6cf266519f5b",
              "name": "data",
              "type": "string",
              "value": "{}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "04b4747c-0bf3-4e41-9bff-b41e2820634c",
      "name": "Write cache.json",
      "type": "n8n-nodes-base.readWriteFile",
      "position": [
        -1380,
        1580
      ],
      "parameters": {
        "options": {},
        "fileName": "./cache.json",
        "operation": "write"
      },
      "typeVersion": 1
    },
    {
      "id": "48b12238-8358-4e68-92be-a7e3a2a80ca1",
      "name": "Convert json to file",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        -1540,
        1580
      ],
      "parameters": {
        "options": {},
        "operation": "toJson"
      },
      "typeVersion": 1.1
    },
    {
      "id": "4908e314-d80a-4cfd-9f0f-01f395550863",
      "name": "Add information about the last breach we alerted",
      "type": "n8n-nodes-base.merge",
      "position": [
        -1560,
        860
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3
    },
    {
      "id": "f8dbd041-11c3-460d-9728-956d0de657d9",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2020,
        1100
      ],
      "parameters": {
        "color": 6,
        "width": 380,
        "height": 240,
        "content": "## Support My Work! \u2764\ufe0f\n\n**\ud83d\udc4b Hello! I'm Audun / xqus** \n\ud83d\udd17 My work: [xqus.com](https://xqus.com)\n\ud83d\udcb8 n8n shop: [xqus.gumroad.com](https://xqus.gumroad.com)\n\n**If you find this workflow helpful**, consider downloading or purchasing it on [Gumroad](https://xqus.gumroad.com/l/hasgi).\n\nYour support helps me create more useful n8n workflows and resources for the community. \n-Thanks a lot! \ud83d\ude4c"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Split Out": {
      "main": [
        [
          {
            "node": "Check for content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set to none": {
      "main": [
        [
          {
            "node": "Add information about the last breach we alerted",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Set empty json": {
      "main": [
        [
          {
            "node": "Convert json to file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Write breach name to file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set breach name": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read last breach": {
      "main": [
        [
          {
            "node": "Get JSON from file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Request breaches": {
      "main": [
        [
          {
            "node": "Read last breach",
            "type": "main",
            "index": 0
          },
          {
            "node": "Add information about the last breach we alerted",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Request breaches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check for content": {
      "main": [
        [
          {
            "node": "Add information about the last breach we alerted",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Set to none",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get JSON from file": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If - check for new": {
      "main": [
        [
          {
            "node": "Set breach name",
            "type": "main",
            "index": 0
          },
          {
            "node": "New breach",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Old breach",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert json to file": {
      "main": [
        [
          {
            "node": "Write cache.json",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Test workflow\u2019": {
      "main": [
        [
          {
            "node": "Set empty json",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add information about the last breach we alerted": {
      "main": [
        [
          {
            "node": "If - check for new",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}