{
  "name": "RSS Digest Lite - Weekly AI Summary Email",
  "nodes": [
    {
      "parameters": {
        "content": "### How it works\nThis workflow turns one RSS or Atom feed into a weekly executive summary email. Every Monday at 08:00 it reads the feed, keeps articles from the last 7 days, removes duplicates by link, and asks an OpenAI-compatible model for a headline, a 120-180 word summary, key themes and the top links. The result is formatted as an HTML email and sent through your SMTP account. If the feed has no recent articles, the workflow stops with a clear error instead of sending an empty digest.\n\n### Setup\n1. Replace the feed URL in Read Your RSS Feed. Any RSS or Atom URL works.\n2. Create an HTTP Header Auth credential with header name Authorization and value Bearer <your API key>. Select it in Write Weekly Summary. The default endpoint is OpenAI; any OpenAI-compatible chat completions endpoint works.\n3. Create an SMTP credential and select it in Send Digest Email. Set a sender address that your SMTP provider allows, then set the recipient.\n4. Run the workflow once manually and check the email before publishing the schedule.\n\n### Customization\nChange the cron expression in Every Monday 08:00, widen or narrow the 7-day window in Collect Last 7 Days, or duplicate Read Your RSS Feed and merge several feeds into the Code node. Tested with n8n 2.48.8 and core nodes only.",
        "height": 440,
        "width": 620,
        "color": 1
      },
      "id": "f1060000-0000-4000-8000-000000000001",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -620,
        -240
      ]
    },
    {
      "parameters": {
        "content": "Reads one feed, keeps the last 7 days and removes duplicate links.",
        "height": 100,
        "width": 520,
        "color": 7
      },
      "id": "f1060000-0000-4000-8000-000000000002",
      "name": "## Collect articles",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -200
      ]
    },
    {
      "parameters": {
        "content": "Produces a headline, a summary, themes and top links as strict JSON.",
        "height": 100,
        "width": 520,
        "color": 7
      },
      "id": "f1060000-0000-4000-8000-000000000003",
      "name": "## Summarize with AI",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        520,
        -200
      ]
    },
    {
      "parameters": {
        "content": "Turns the summary into HTML and sends it through SMTP.",
        "height": 100,
        "width": 560,
        "color": 7
      },
      "id": "f1060000-0000-4000-8000-000000000004",
      "name": "## Format and send",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1040,
        -200
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * 1"
            }
          ]
        }
      },
      "id": "f1060000-0000-4000-8000-000000000010",
      "name": "Every Monday 08:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "url": "https://REPLACE_WITH_FEED_URL",
        "options": {}
      },
      "id": "f1060000-0000-4000-8000-000000000011",
      "name": "Read Your RSS Feed",
      "type": "n8n-nodes-base.rssFeedRead",
      "typeVersion": 1.2,
      "position": [
        260,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const cutoff = Date.now() - 7 * 24 * 60 * 60 * 1000;\nconst seen = new Set();\nconst articles = [];\nfor (const item of $input.all()) {\n  const a = item.json;\n  const ts = new Date(a.isoDate || a.pubDate || 0).getTime();\n  if (ts && ts < cutoff) continue;\n  const link = String(a.link || '').trim();\n  const key = link || String(a.title || '').trim();\n  if (!key || seen.has(key)) continue;\n  seen.add(key);\n  const text = String(a.contentSnippet || a.content || a.summary || '').replace(/<[^>]+>/g, ' ').replace(/\\s+/g, ' ').trim().slice(0, 500);\n  articles.push({\n    title: a.title || 'Untitled',\n    link,\n    published: a.isoDate || a.pubDate || '',\n    excerpt: text,\n  });\n}\nif (!articles.length) throw new Error('No articles in the last 7 days. Check the feed URL and its publish dates.');\nconst top = articles.slice(0, 40);\nreturn [{ json: {\n  article_count: top.length,\n  articles_json: JSON.stringify(top),\n  ai_user_prompt: 'Summarize these articles for a busy operator. Return strict JSON only: {\"headline\": \"<one line>\", \"summary\": \"<120-180 word summary>\", \"themes\": [\"<3-5 short themes>\"], \"top_links\": [\"<up to 5 URLs>\"]}. Articles:\\n' + JSON.stringify(top),\n} }];"
      },
      "id": "f1060000-0000-4000-8000-000000000012",
      "name": "Collect Last 7 Days",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        520,
        0
      ]
    },
    {
      "parameters": {
        "url": "https://api.openai.com/v1/chat/completions",
        "method": "POST",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ model: 'gpt-4o-mini', temperature: 0.3, response_format: { type: 'json_object' }, messages: [ { role: 'system', content: 'You are an executive analyst. Summarize only what the provided articles say. Return strict JSON.' }, { role: 'user', content: $json.ai_user_prompt } ] }) }}",
        "options": {
          "timeout": 90000
        }
      },
      "id": "f1060000-0000-4000-8000-000000000013",
      "name": "Write Weekly Summary",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        780,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const raw = $json.choices?.[0]?.message?.content ?? '{}';\nlet parsed = {};\ntry { parsed = JSON.parse(raw); } catch (e) {\n  const m = String(raw).match(/\\{[\\s\\S]*\\}/);\n  if (m) { try { parsed = JSON.parse(m[0]); } catch (e2) {} }\n}\nconst themes = Array.isArray(parsed.themes) ? parsed.themes : [];\nconst links = Array.isArray(parsed.top_links) ? parsed.top_links : [];\nconst esc = (s) => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\nconst html = '<h2>' + esc(parsed.headline || 'Weekly digest') + '</h2>' + '<p>' + esc(parsed.summary || 'No summary generated.') + '</p>' + '<h3>Themes</h3><ul>' + themes.map((t) => '<li>' + esc(t) + '</li>').join('') + '</ul>' + '<h3>Top links</h3><ul>' + links.map((u) => '<li><a href=\"' + esc(u) + '\">' + esc(u) + '</a></li>').join('') + '</ul>';\nreturn [{ json: {\n  subject: 'Weekly digest: ' + (parsed.headline || 'your industry update'),\n  email_html: html,\n  headline: parsed.headline || '',\n  themes_text: themes.join(', '),\n} }];"
      },
      "id": "f1060000-0000-4000-8000-000000000014",
      "name": "Format Email",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1040,
        0
      ]
    },
    {
      "parameters": {
        "fromEmail": "REPLACE_WITH_SENDER@example.com",
        "toEmail": "REPLACE_WITH_RECIPIENT@example.com",
        "subject": "={{ $json.subject }}",
        "emailFormat": "html",
        "html": "={{ $json.email_html }}",
        "options": {
          "appendAttribution": false
        }
      },
      "id": "f1060000-0000-4000-8000-000000000015",
      "name": "Send Digest Email",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        1300,
        0
      ]
    }
  ],
  "pinData": {},
  "connections": {
    "Every Monday 08:00": {
      "main": [
        [
          {
            "node": "Read Your RSS Feed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Your RSS Feed": {
      "main": [
        [
          {
            "node": "Collect Last 7 Days",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect Last 7 Days": {
      "main": [
        [
          {
            "node": "Write Weekly Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write Weekly Summary": {
      "main": [
        [
          {
            "node": "Format Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Email": {
      "main": [
        [
          {
            "node": "Send Digest Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "freebie-rss-digest-lite",
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}
