{
  "name": "RSS daily new posts digest (Skillaisle)",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            { "field": "cronExpression", "expression": "0 8 * * 1-5" }
          ]
        }
      },
      "id": "b7e1c2d3-0002-4000-8000-000000000001",
      "name": "Weekdays 08:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [0, 0]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            { "id": "b7e1c2d3-0002-4000-8000-0000000000c1", "name": "feed_url", "value": "https://example.com/feed.xml", "type": "string" },
            { "id": "b7e1c2d3-0002-4000-8000-0000000000c2", "name": "hours_back", "value": 24, "type": "number" }
          ]
        },
        "options": {}
      },
      "id": "b7e1c2d3-0002-4000-8000-000000000002",
      "name": "Config",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [240, 0]
    },
    {
      "parameters": {
        "url": "={{ $json.feed_url }}",
        "options": {}
      },
      "id": "b7e1c2d3-0002-4000-8000-000000000003",
      "name": "Read feed",
      "type": "n8n-nodes-base.rssFeedRead",
      "typeVersion": 1.1,
      "position": [480, 0]
    },
    {
      "parameters": {
        "jsCode": "const cfg = $('Config').first().json;\nconst hours = Number(cfg.hours_back) || 24;\nconst cutoff = Date.now() - hours * 3600 * 1000;\nlet skipped = 0;\nconst fresh = [];\nfor (const it of items) {\n  const j = it.json;\n  const raw = j.isoDate || j.pubDate;\n  const t = raw ? Date.parse(raw) : NaN;\n  if (Number.isNaN(t)) { skipped++; continue; }\n  if (t >= cutoff) fresh.push({ title: j.title || '(untitled)', link: j.link || '', date: new Date(t).toISOString() });\n}\nfresh.sort((a, b) => b.date.localeCompare(a.date));\nconst lines = [`# New posts in the last ${hours}h`, '', `Feed: ${cfg.feed_url}`, `Generated: ${new Date().toISOString()}`, ''];\nif (fresh.length === 0) lines.push('No new posts.');\nfor (const p of fresh) lines.push(`- [${p.title}](${p.link}) (${p.date.slice(0, 10)})`);\nif (skipped) lines.push('', `Skipped ${skipped} item(s) with no publish date.`);\nreturn [{ json: { digest: lines.join('\\n'), count: fresh.length } }];"
      },
      "id": "b7e1c2d3-0002-4000-8000-000000000004",
      "name": "Build digest",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [720, 0]
    },
    {
      "parameters": {
        "operation": "toText",
        "sourceProperty": "digest",
        "options": { "fileName": "rss-digest.md" }
      },
      "id": "b7e1c2d3-0002-4000-8000-000000000005",
      "name": "Digest file",
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [960, 0]
    }
  ],
  "connections": {
    "Weekdays 08:00": { "main": [ [ { "node": "Config", "type": "main", "index": 0 } ] ] },
    "Config": { "main": [ [ { "node": "Read feed", "type": "main", "index": 0 } ] ] },
    "Read feed": { "main": [ [ { "node": "Build digest", "type": "main", "index": 0 } ] ] },
    "Build digest": { "main": [ [ { "node": "Digest file", "type": "main", "index": 0 } ] ] }
  },
  "settings": { "executionOrder": "v1" },
  "pinData": {}
}
