{
  "name": "Daily Catat Reminder (14:00 & 20:00)",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 14 * * *"
            }
          ]
        }
      },
      "id": "schedule-siang",
      "name": "Schedule 14:00 WIB",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.1,
      "position": [
        240,
        200
      ],
      "notes": "Penting: pastikan timezone n8n di-set ke Asia/Jakarta. Settings \u2192 Personal \u2192 Time Zone."
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 20 * * *"
            }
          ]
        }
      },
      "id": "schedule-malam",
      "name": "Schedule 20:00 WIB",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.1,
      "position": [
        240,
        400
      ]
    },
    {
      "parameters": {
        "jsCode": "// Tentukan slot berdasarkan jam saat ini\nconst now = new Date();\nconst hour = now.getHours();\nconst slot = hour < 18 ? 'daily_reminder_siang' : 'daily_reminder_malam';\n\nreturn [{ json: { mode: slot } }];"
      },
      "id": "determine-slot",
      "name": "Tentukan Slot",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $env.DASHBOARD_URL }}/api/push/broadcast",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $env.INTERNAL_API_TOKEN }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"mode\": \"{{ $json.mode }}\"\n}",
        "options": {
          "timeout": 60000
        }
      },
      "id": "broadcast-push",
      "name": "Broadcast Push (siang/malam)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        680,
        300
      ],
      "notes": "Backend dashboard yang handle:\n- Filter user dengan push_daily_reminder=true\n- Filter user status=aktif\n- Dedup via push_notification_log (gak akan kirim 2x untuk slot yang sama)\n- Kirim push notif paralel"
    }
  ],
  "connections": {
    "Schedule 14:00 WIB": {
      "main": [
        [
          {
            "node": "Tentukan Slot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule 20:00 WIB": {
      "main": [
        [
          {
            "node": "Tentukan Slot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tentukan Slot": {
      "main": [
        [
          {
            "node": "Broadcast Push (siang/malam)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    {
      "name": "nayyira"
    },
    {
      "name": "push"
    },
    {
      "name": "daily"
    }
  ]
}