{
  "id": "Hghs04k6T6BZZvRK",
  "name": "creator/newsletter",
  "tags": [],
  "nodes": [
    {
      "id": "df0357d5-0a30-4565-ac56-e04dae36afb6",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -224,
        192
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "executeOnce": false,
      "retryOnFail": true,
      "typeVersion": 1.3
    },
    {
      "id": "ae114260-e59b-4ed4-88ae-255559ef5cae",
      "name": "RSS Read",
      "type": "n8n-nodes-base.rssFeedRead",
      "position": [
        0,
        0
      ],
      "parameters": {
        "url": "https://feeds.bbci.co.uk/news/world/rss.xml",
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "d0e01961-98a6-4151-99d7-fd57de73cd90",
      "name": "RSS Read1",
      "type": "n8n-nodes-base.rssFeedRead",
      "position": [
        0,
        192
      ],
      "parameters": {
        "url": "https://abcnews.go.com/abcnews/internationalheadlines",
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "f6425293-6e64-436c-95c8-89d0b73dce86",
      "name": "RSS Read2",
      "type": "n8n-nodes-base.rssFeedRead",
      "position": [
        0,
        384
      ],
      "parameters": {
        "url": "https://www.theguardian.com/world/rss",
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "e171c66d-184e-4455-ada2-28c0004598ec",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        224,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "63b9b0af-4da4-4852-aa97-948157729670",
              "name": "title",
              "type": "string",
              "value": "={{ $json.title }}"
            },
            {
              "id": "70fde169-aeaa-4832-a0b9-6cba1af59af3",
              "name": "pubDate",
              "type": "string",
              "value": "={{ $json.pubDate }}"
            },
            {
              "id": "8bb5a569-b86b-42a0-8286-1537acd57602",
              "name": "content",
              "type": "string",
              "value": "={{ $json.content }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9ecc1eaf-933d-47c5-9514-6ff23ed89161",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        448,
        176
      ],
      "parameters": {
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "bc259244-718f-4373-a2c2-2bba530af9a2",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        896,
        192
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "5b136123-35c4-45bd-947d-a752a9a5f0f2",
              "operator": {
                "type": "dateTime",
                "operation": "after"
              },
              "leftValue": "={{ $json.pubDate }}",
              "rightValue": "={{ $json.cutoff }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "48404985-be89-45be-840d-2788f16a393b",
      "name": "Remove Duplicates",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        1120,
        192
      ],
      "parameters": {
        "compare": "allFieldsExcept",
        "options": {},
        "fieldsToExclude": "cutoff"
      },
      "typeVersion": 2
    },
    {
      "id": "9a59b9af-ee07-427d-8ad8-e6801d890713",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2368,
        192
      ],
      "parameters": {
        "message": "={{$json.result}}",
        "options": {},
        "subject": "World News "
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b6f489c7-7dca-4450-9a6d-6a85468dfec7",
      "name": "Edit Fields1 _ cutoff",
      "type": "n8n-nodes-base.set",
      "position": [
        672,
        192
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ef66d3dd-9edf-430d-826e-73e59174fb4e",
              "name": "pubDate",
              "type": "string",
              "value": "={{ $json.pubDate }}"
            },
            {
              "id": "f5a909ce-b394-4f91-9b8d-4563b8adef03",
              "name": "cutoff",
              "type": "string",
              "value": "={{ $now.minus({ hours: 24 }).toISO() }}"
            },
            {
              "id": "6cd2c18c-ce22-4ec9-bbc7-eebc503b98a0",
              "name": "title",
              "type": "string",
              "value": "={{ $json.title }}"
            },
            {
              "id": "861f15bb-208f-493d-a63c-07191aea2d24",
              "name": "content",
              "type": "string",
              "value": "={{ $json.content }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0334cfa9-4ffa-4136-988b-a06cc7926bed",
      "name": "Edit Fields1",
      "type": "n8n-nodes-base.set",
      "position": [
        224,
        192
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "63b9b0af-4da4-4852-aa97-948157729670",
              "name": "title",
              "type": "string",
              "value": "={{ $json.title }}"
            },
            {
              "id": "70fde169-aeaa-4832-a0b9-6cba1af59af3",
              "name": "pubDate",
              "type": "string",
              "value": "={{ $json.pubDate }}"
            },
            {
              "id": "8bb5a569-b86b-42a0-8286-1537acd57602",
              "name": "content",
              "type": "string",
              "value": "={{ $json.content }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6c6602f1-f6ac-4b1a-8149-2206b3a32175",
      "name": "Edit Fields2",
      "type": "n8n-nodes-base.set",
      "position": [
        224,
        384
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "63b9b0af-4da4-4852-aa97-948157729670",
              "name": "title",
              "type": "string",
              "value": "={{ $json.title }}"
            },
            {
              "id": "70fde169-aeaa-4832-a0b9-6cba1af59af3",
              "name": "pubDate",
              "type": "string",
              "value": "={{ $json.pubDate }}"
            },
            {
              "id": "8bb5a569-b86b-42a0-8286-1537acd57602",
              "name": "content",
              "type": "string",
              "value": "={{ $json.content }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0b00f0fe-71a6-4e94-9700-c507895515bf",
      "name": "Sort and Select Top 10",
      "type": "n8n-nodes-base.code",
      "position": [
        1344,
        192
      ],
      "parameters": {
        "jsCode": "const items = $input.all().map((item) => item.json);\n\nconst sortedItems = items.sort(\n  (a, b) => new Date(b.pubDate) - new Date(a.pubDate)\n);\n\nconst top10Items = sortedItems.slice(0, 10);\n\nreturn top10Items.map(item => ({ json: item }));"
      },
      "typeVersion": 2
    },
    {
      "id": "59d8aa2b-302c-4647-bfb1-ecdf7c0677e8",
      "name": "Format Email",
      "type": "n8n-nodes-base.code",
      "position": [
        2144,
        192
      ],
      "parameters": {
        "jsCode": "const rewrittenText = $input.first().json.output;\n\nconst now = new Date();\nconst day = now.getDate();\nconst months = ['January','February','March','April','May','June',\n                'July','August','September','October','November','December'];\nconst month = months[now.getMonth()];\n\nconst header = '<b>The most important information from the last 24 hours</b><br>'\n             + '<b>' + day + ' ' + month + '</b><br><br>';\n\nconst cleanContent = rewrittenText\n  .replace(/Tytu[\u0142l]\\s*:/gi, '')\n  .replace(/<[^>]*>/g, '')\n  .replace(/https?:\\/\\/\\S+/g, '')\n  .replace(/&[a-z]+;/gi, ' ')\n  .replace(/\\s+/g, ' ')\n  .trim()\n  .replace(/\\n/g, '<br>');\n\nreturn [{ json: { result: header + cleanContent } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "559ba335-78f2-4f55-8231-317baa6da47b",
      "name": "Google Gemini Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1872,
        416
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "18bf7700-5e42-40be-b320-d51f30921565",
      "name": "Combine Articles",
      "type": "n8n-nodes-base.code",
      "position": [
        1568,
        192
      ],
      "parameters": {
        "jsCode": "const items = $input.all().map((item) => item.json);\n\nconst combined = items.map((item, index) => {\n  return (index + 1) + \". \" + item.title + \"\\n\" + item.content;\n}).join(\"\\n\\n\");\n\nreturn [{ json: { combinedArticles: combined } }];"
      },
      "executeOnce": true,
      "typeVersion": 2
    },
    {
      "id": "fc500020-4a39-4ce3-8b8f-d845f6fedc67",
      "name": "Rewrite All Articles",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1792,
        192
      ],
      "parameters": {
        "text": "=Rewrite the articles below in your own words while preserving all key information and facts. Change the sentence structure and use synonyms, but do not alter the meaning. Each article should be unique and should not be a copy of the original. Keep the article numbering intact.\n\n{{ $json.combinedArticles }}",
        "options": {
          "systemMessage": "You are an expert content editor. Your task is to rewrite articles in a unique way, preserving all facts and information while changing the structure and vocabulary so that the text is original."
        },
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "f8528a8e-b13c-4993-aad6-c80cc312699d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -672,
        -912
      ],
      "parameters": {
        "width": 496,
        "height": 608,
        "content": " \ud83d\udcf0 AI-Powered RSS Newsletter Generator\n\nAutomatically fetches news from 3 RSS feeds, removes duplicates and\noutdated items, selects the top 10 articles, rewrites them using\nGoogle Gemini, and sends a ready-to-read newsletter by email \u2014\nfully automated on a schedule.\n\n### Required credentials:\n- Google Gemini API key\n- Gmail (or other SMTP) account for sending the email\n\n### Before you run this workflow:\n1. Replace the feed URLs in \"RSS Read\" / \"RSS Read1\" / \"RSS Read2\"\n   with your own sources\n2. Connect your own Google Gemini API key in \"Google Gemini Model\"\n3. Connect your Gmail account in \"Send a message\" and set the\n   recipient email address\n4. Adjust the schedule in \"Schedule Trigger\" to fit your needs"
      },
      "typeVersion": 1
    },
    {
      "id": "acabdff4-4a7d-4b8a-a507-2f27eb12e8ee",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        -448
      ],
      "parameters": {
        "width": 432,
        "height": 1008,
        "content": "### \ud83d\udce5 Fetching news\nThree independent RSS sources. No credentials required \u2014 these are\npublic feeds. Each feed is cleaned and normalized by \"Edit Fields\"\nso the data (title, link, content, publish date) has a consistent\nformat before merging.\n\n\u26a0\ufe0f Setup: Replace the feed URL in each \"RSS Read\" node with your\nown source."
      },
      "typeVersion": 1
    },
    {
      "id": "04bc329d-f230-43ad-b62e-882b99298d26",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        -448
      ],
      "parameters": {
        "width": 192,
        "height": 1008,
        "content": "\ud83d\udd00 Merging sources\nCombines the results from all RSS feeds into a single list for\nfurther processing."
      },
      "typeVersion": 1
    },
    {
      "id": "246cfbd6-8891-4ee8-b70c-5c3d6a411053",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        624,
        -448
      ],
      "parameters": {
        "width": 432,
        "height": 1008,
        "content": "\u23f1\ufe0f Time filter\nDiscards news older than a set threshold (e.g. 24h), so the\nnewsletter only includes fresh content."
      },
      "typeVersion": 1
    },
    {
      "id": "621ccd9a-8c3b-44b2-9c03-89ef681d8fcc",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1088,
        -448
      ],
      "parameters": {
        "width": 416,
        "height": 1008,
        "content": "\ud83e\uddf9 Deduplication and ranking\nRemoves duplicate news items (by link/title) and selects the top 10\nbased on keyword matching against topic categories (score)."
      },
      "typeVersion": 1
    },
    {
      "id": "a446c3d3-9288-42f5-a9b8-7d443a404d19",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1536,
        -448
      ],
      "parameters": {
        "width": 208,
        "height": 1008,
        "content": "\ud83d\udce6 Preparing data for AI\nCombines the selected 10 articles into a single text/JSON block,\nready to be passed to the AI agent."
      },
      "typeVersion": 1
    },
    {
      "id": "3d2eadb9-6dc1-4513-afa1-fac664ebe1a6",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2112,
        -448
      ],
      "parameters": {
        "width": 480,
        "height": 1008,
        "content": "\u2709\ufe0f Sending the newsletter\nFormats the AI output into a ready-to-send email and delivers it\nvia Gmail to the specified recipient.\n\n\u26a0\ufe0f Setup: This node requires a Gmail account connection.\n1. Open the \"Send a message\" node\n2. Under Credentials, click \"Create New\" \u2192 \"Gmail OAuth2\"\n3. Sign in with your Google account and grant access\n4. Set the recipient email address in the node parameters"
      },
      "typeVersion": 1
    },
    {
      "id": "a7b38f92-ee95-4120-9e7c-b4d86b85bd8f",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1776,
        -448
      ],
      "parameters": {
        "width": 304,
        "height": 1008,
        "content": "\ud83e\udd16 AI content rewriting\nThe AI Agent (Google Gemini) rewrites the articles into a\nconsistent, readable newsletter format \u2014 shortening, unifying tone,\nand removing unnecessary details.\n\n\u26a0\ufe0f Setup: This node requires a Google Gemini API key.\n1. Open the \"Google Gemini Model\" node\n2. Under Credentials, click \"Create New\"\n3. Paste your API key from https://aistudio.google.com/app/apikey"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "3812fe59-640b-4163-b446-9467e830e2ac",
  "nodeGroups": [],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Remove Duplicates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Edit Fields1 _ cutoff",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RSS Read": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RSS Read1": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RSS Read2": {
      "main": [
        [
          {
            "node": "Edit Fields2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Edit Fields2": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Format Email": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Articles": {
      "main": [
        [
          {
            "node": "Rewrite All Articles",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "RSS Read",
            "type": "main",
            "index": 0
          },
          {
            "node": "RSS Read2",
            "type": "main",
            "index": 0
          },
          {
            "node": "RSS Read1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicates": {
      "main": [
        [
          {
            "node": "Sort and Select Top 10",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Model": {
      "ai_languageModel": [
        [
          {
            "node": "Rewrite All Articles",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Rewrite All Articles": {
      "main": [
        [
          {
            "node": "Format Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields1 _ cutoff": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sort and Select Top 10": {
      "main": [
        [
          {
            "node": "Combine Articles",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}