{
  "name": "RSS Weekly Digest",
  "nodes": [
    {
      "id": "n1",
      "name": "Every Monday at 8:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 8
            }
          ]
        }
      }
    },
    {
      "id": "n2",
      "name": "Read RSS feed",
      "type": "n8n-nodes-base.rssFeedRead",
      "typeVersion": 1,
      "position": [
        220,
        0
      ],
      "parameters": {
        "url": "https://example.com/feed/",
        "options": {}
      }
    },
    {
      "id": "n3",
      "name": "Keep last 7 days",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        440,
        0
      ],
      "parameters": {
        "jsCode": "// Keep only items published in the last 7 days.\nconst weekAgo = Date.now() - 7 * 24 * 60 * 60 * 1000;\nreturn $input.all().filter(item => {\n  const date = new Date(item.json.isoDate || item.json.pubDate || 0).getTime();\n  return date >= weekAgo;\n});"
      }
    },
    {
      "id": "n4",
      "name": "Build email",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        0
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// Build one HTML email from all items.\nconst items = $input.all();\nconst esc = s => String(s || '').replace(/[&<>\"]/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','\"':'&quot;'}[c]));\nconst list = items.map(i => `<li><a href=\"${esc(i.json.link)}\">${esc(i.json.title)}</a><br>${esc((i.json.contentSnippet || '').slice(0, 200))}</li>`).join('');\nconst html = items.length\n  ? `<h2>This week: ${items.length} new posts</h2><ul>${list}</ul>`\n  : '<p>No new posts this week.</p>';\nreturn [{ json: { subject: `Weekly digest: ${items.length} new posts`, html } }];"
      }
    },
    {
      "id": "n5",
      "name": "Send digest",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        880,
        0
      ],
      "parameters": {
        "fromEmail": "digest@example.com",
        "toEmail": "you@example.com",
        "subject": "={{ $json.subject }}",
        "emailFormat": "html",
        "html": "={{ $json.html }}",
        "options": {}
      },
      "credentials": {
        "smtp": {
          "name": "SMTP account"
        }
      }
    },
    {
      "id": "note",
      "name": "Setup notes",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -320
      ],
      "parameters": {
        "content": "## Setup\n1. Replace the feed URL in **Read RSS feed**.\n2. Add your SMTP credentials in **Send digest** and set your own addresses.\n3. Run once with *Execute workflow*, then activate.",
        "width": 380,
        "height": 260
      }
    }
  ],
  "connections": {
    "Every Monday at 8:00": {
      "main": [
        [
          {
            "node": "Read RSS feed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read RSS feed": {
      "main": [
        [
          {
            "node": "Keep last 7 days",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep last 7 days": {
      "main": [
        [
          {
            "node": "Build email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build email": {
      "main": [
        [
          {
            "node": "Send digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "tags": []
}