{
  "name": "Apier — Norwegian deadline alerts to Slack",
  "id": "apier-deadlines-slack",
  "versionId": "1.0.0",
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "timezone": "Europe/Oslo"
  },
  "nodes": [
    {
      "id": "11111111-1111-4111-8111-111111111111",
      "name": "Cron — daily 09:00 Europe/Oslo",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.1,
      "position": [240, 320],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 * * *"
            }
          ]
        },
        "timezone": "Europe/Oslo"
      }
    },
    {
      "id": "22222222-2222-4222-8222-222222222222",
      "name": "HTTP — Apier sandbox /deadlines",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [520, 320],
      "parameters": {
        "method": "GET",
        "url": "https://apier.no/api/v1/sandbox/public/company/999999999/deadlines",
        "authentication": "none",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      }
    },
    {
      "id": "66666666-6666-4666-8666-666666666666",
      "name": "Split Out — data.deadlines[]",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [760, 320],
      "parameters": {
        "fieldToSplitOut": "data.deadlines",
        "options": {}
      }
    },
    {
      "id": "33333333-3333-4333-8333-333333333333",
      "name": "Filter — within 7 days",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [1000, 320],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "44444444-4444-4444-8444-444444444444",
              "leftValue": "={{ Math.floor((new Date($json.deadline_at).getTime() - Date.now()) / (1000 * 60 * 60 * 24)) }}",
              "rightValue": 7,
              "operator": {
                "type": "number",
                "operation": "lte"
              }
            },
            {
              "id": "44444444-4444-4444-8444-444444444445",
              "leftValue": "={{ Math.floor((new Date($json.deadline_at).getTime() - Date.now()) / (1000 * 60 * 60 * 24)) }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            }
          ],
          "combinator": "and"
        }
      }
    },
    {
      "id": "55555555-5555-4555-8555-555555555555",
      "name": "Slack — post alert",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [1280, 320],
      "parameters": {
        "resource": "message",
        "operation": "post",
        "authentication": "webhook",
        "webhookUrl": "https://hooks.slack.com/services/REPLACE-ME/REPLACE-ME/REPLACE-ME",
        "text": "Norwegian deadline due soon: {{ $json.obligation_id }} on {{ $json.deadline_at }} ({{ $json.legal_reference }})",
        "otherOptions": {
          "mrkdwn": true
        }
      }
    }
  ],
  "connections": {
    "Cron — daily 09:00 Europe/Oslo": {
      "main": [
        [
          {
            "node": "HTTP — Apier sandbox /deadlines",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP — Apier sandbox /deadlines": {
      "main": [
        [
          {
            "node": "Split Out — data.deadlines[]",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out — data.deadlines[]": {
      "main": [
        [
          {
            "node": "Filter — within 7 days",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter — within 7 days": {
      "main": [
        [
          {
            "node": "Slack — post alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
