{
  "name": "GFM 04 \u2014 Weekly Summary (Mondays 08:00 UTC)",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * 1"
            }
          ]
        }
      },
      "id": "node-cron-mon",
      "name": "Schedule \u2014 Monday 08:00 UTC",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "url": "={{$env.API_BASE || 'https://fdi-backend-api.gentleglacier-ae9701ca.uaenorth.azurecontainerapps.io'}}/api/v1/reports/weekly-digest",
        "method": "GET",
        "options": {
          "timeout": 60000,
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      },
      "id": "node-http-digest",
      "name": "GET /reports/weekly-digest",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        480,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "// Subscriber list \u2014 replace with real list or load from env / DB\nconst subscribers = ($env && $env.WEEKLY_SUBSCRIBERS ? $env.WEEKLY_SUBSCRIBERS.split(',') : ['melsaadany@fdimonitor.org']);\nconst html = $json.html || `<h1>GFM Weekly Digest</h1><pre>${JSON.stringify($json, null, 2)}</pre>`;\nreturn subscribers.map(to => ({ json: { to: to.trim(), subject: $json.subject || 'GFM Weekly FDI Digest', html } }));"
      },
      "id": "node-build",
      "name": "Build subscriber payload",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        720,
        300
      ]
    },
    {
      "parameters": {
        "fromEmail": "digest@fdimonitor.org",
        "toEmail": "={{$json.to}}",
        "subject": "={{$json.subject}}",
        "html": "={{$json.html}}",
        "options": {}
      },
      "id": "node-email-digest",
      "name": "Email \u2014 Weekly Digest",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        960,
        300
      ],
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Schedule \u2014 Monday 08:00 UTC": {
      "main": [
        [
          {
            "node": "GET /reports/weekly-digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GET /reports/weekly-digest": {
      "main": [
        [
          {
            "node": "Build subscriber payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build subscriber payload": {
      "main": [
        [
          {
            "node": "Email \u2014 Weekly Digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "saveExecutionProgress": true,
    "saveManualExecutions": true,
    "saveDataErrorExecution": "all",
    "saveDataSuccessExecution": "all"
  },
  "tags": [
    {
      "name": "gfm"
    },
    {
      "name": "digest"
    }
  ],
  "versionId": "phase14-04"
}