{
  "name": "Profundis Discord alerts",
  "nodes": [
    {
      "parameters": {
        "url": "https://api.profundis.io/api/v2/sse/common/alerting?api_key=YOUR-API-KEY-HERE"
      },
      "type": "n8n-nodes-base.sseTrigger",
      "typeVersion": 1,
      "position": [
        -220,
        -280
      ],
      "id": "55b2cd20-0153-49d1-9e7d-cb11c44f4d36",
      "name": "SSE Trigger"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.type }}",
                    "rightValue": "heartbeat",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "id": "7e926ed9-0a6c-45ca-9aa8-f8c2577083f4"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "heartbeat"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "1afbb991-d060-4f80-8bb2-da054ac8aed4",
                    "leftValue": "={{ $json.type }}",
                    "rightValue": "alert",
                    "operator": {
                      "type": "string",
                      "operation": "equals",
                      "name": "filter.operator.equals"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "alert"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        0,
        -280
      ],
      "id": "4067968a-99bd-4abd-ab53-0613d33d313d",
      "name": "Switch"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        220,
        -380
      ],
      "id": "7c403882-119b-4786-a45c-b4d93b0f3e9e",
      "name": "No Operation, do nothing"
    },
    {
      "parameters": {
        "jsCode": "for (const item of $input.all()) {\n  if (item.json.type == \"alert\") {\n    return item.json.alert\n  }\n}\n\nreturn $input.all();"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        220,
        -180
      ],
      "id": "41d4f09f-e701-44de-8160-701eb8f4ac7d",
      "name": "Code"
    },
    {
      "parameters": {
        "authentication": "webhook",
        "content": "=**🚨 new alert received!**\n\n**link:** {{$json.protocol}}://{{$json.host}}:{{$json.port}} {{$json.status_code}} ({{$json.status_code_message}}) ({{$json.ip}})\n**title:** `{{$json.title}} `\n**content length:** `{{$json.content_length}} bytes`\n**technologies:** `{{$json.technologies.join(\", \")}} `\n**cert subj:** `{{$json.cert_subj}} `\n**profundis link:** https://profundis.io/tools/hosts-details?search={{$json.host}}\n\n------------------------------------------------------------------------------------\n",
        "options": {}
      },
      "type": "n8n-nodes-base.discord",
      "typeVersion": 2,
      "position": [
        440,
        -180
      ],
      "id": "42455d92-9478-4bce-a7f5-10936f61bb19",
      "name": "Discord",
      "webhookId": "YOUR-DISCORD-WEBHOOK-ID",
      "notesInFlow": false,
      "credentials": {
        "discordWebhookApi": {
          "id": "YOUR-DISCORD-CRED-ID",
          "name": "Discord Webhook account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "SSE Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Discord",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Discord": {
      "main": [
        []
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "98052855-95f8-4b4e-b4c6-1483be71cc5f",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "f4480e075519b21d19ed82b6110683993ddfed3155bf78e072282938dd15f0f5"
  },
  "id": "DRWQXIiC4jaSRwPP",
  "tags": []
}
