{
  "name": "World News Collector (10m)",
  "nodes": [
    {
      "parameters": {
        "url": "https://feeds.bbci.co.uk/news/world/rss.xml",
        "options": {}
      },
      "id": "727276d4-cc00-493c-9e94-b044f43a1d6b",
      "name": "BBC RSS",
      "type": "n8n-nodes-base.rssFeedRead",
      "typeVersion": 1,
      "position": [
        416,
        -160
      ]
    },
    {
      "parameters": {
        "url": "https://feeds.abcnews.com/abcnews/topstories",
        "options": {}
      },
      "id": "68a7beab-5f8d-46ea-9c2f-5a442bc06157",
      "name": "ABC RSS",
      "type": "n8n-nodes-base.rssFeedRead",
      "typeVersion": 1,
      "position": [
        416,
        0
      ]
    },
    {
      "parameters": {
        "url": "https://time.com/feed/",
        "options": {}
      },
      "id": "20a91b5e-5a04-413b-a28b-af714a77b893",
      "name": "TIME RSS",
      "type": "n8n-nodes-base.rssFeedRead",
      "typeVersion": 1,
      "position": [
        416,
        160
      ]
    },
    {
      "parameters": {
        "fields": {
          "values": [
            {
              "name": "source",
              "stringValue": "BBC World News"
            }
          ]
        },
        "options": {}
      },
      "id": "e805be8e-a51a-43de-85e8-1b272af22e83",
      "name": "Tag Source (BBC)",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.2,
      "position": [
        656,
        -160
      ]
    },
    {
      "parameters": {
        "fields": {
          "values": [
            {
              "name": "source",
              "stringValue": "ABC News"
            }
          ]
        },
        "options": {}
      },
      "id": "d7e832af-4d01-4793-96c0-a629646fb185",
      "name": "Tag Source (ABC)",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.2,
      "position": [
        656,
        0
      ]
    },
    {
      "parameters": {
        "fields": {
          "values": [
            {
              "name": "source",
              "stringValue": "TIME"
            }
          ]
        },
        "options": {}
      },
      "id": "92da7ebe-ed54-4850-aded-929aaa298e23",
      "name": "Tag Source (TIME)",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.2,
      "position": [
        656,
        160
      ]
    },
    {
      "parameters": {},
      "id": "85914b5b-b0f8-4b88-bb5c-4c8c169ce459",
      "name": "Merge BBC+ABC",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2,
      "position": [
        896,
        -80
      ]
    },
    {
      "parameters": {},
      "id": "81446276-f19a-40f2-a835-3312e5f97ee4",
      "name": "Merge All",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2,
      "position": [
        1136,
        48
      ]
    },
    {
      "parameters": {
        "functionCode": "const parseDate = (value) => {\n  const t = new Date(value).getTime();\n  return Number.isFinite(t) ? new Date(t).toISOString() : null;\n};\n\n// Normalize, dedupe within this run, prune obvious empties\nconst seen = new Set();\nconst output = [];\n\nfor (const item of items) {\n  const link = item.json.link || item.json.id;\n  const title = item.json.title || '';\n  const description = item.json.contentSnippet || item.json.content || '';\n  const pubDate = parseDate(item.json.isoDate || item.json.pubDate || item.json.published);\n  const source = item.json.source || 'Unknown';\n\n  if (!link || !pubDate) continue;\n  if (seen.has(link)) continue;\n  seen.add(link);\n\n  output.push({\n    json: {\n      link,\n      title,\n      description,\n      source,\n      pubDate,\n      collectedAt: new Date().toISOString()\n    }\n  });\n}\n\nreturn output;\n"
      },
      "id": "3ba069dc-ce20-422b-be50-08a0fdd90af8",
      "name": "Normalize + Dedupe",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        1376,
        48
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "*/10 * * * *"
            }
          ]
        }
      },
      "id": "dcb3e1a2-9cd3-4b04-9177-09ab5904daed",
      "name": "Cron (10m)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        176,
        0
      ]
    },
    {
      "parameters": {
        "operation": "upsert",
        "dataTableId": {
          "__rl": true,
          "value": "YOUR_TABLE",
          "mode": "list"
        },
        "filters": {
          "conditions": [
            {
              "keyName": "link",
              "keyValue": "={{ $json.link }}"
            }
          ]
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "link": "={{ $json.link }}",
            "title": "={{ $json.title }}",
            "description": "={{ $json.description }}",
            "source": "={{ $json.source }}",
            "pubDate": "={{ $json.pubDate }}",
            "collectedAt": "={{ $json.collectedAt }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "link",
              "displayName": "link",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "title",
              "displayName": "title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "description",
              "displayName": "description",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "source",
              "displayName": "source",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "pubDate",
              "displayName": "pubDate",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            },
            {
              "id": "collectedAt",
              "displayName": "collectedAt",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "readOnly": false,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "dryRun": false
        }
      },
      "type": "n8n-nodes-base.dataTable",
      "typeVersion": 1,
      "position": [
        1584,
        48
      ],
      "id": "610226de-06f0-41b2-8c8e-626a1438793f",
      "name": "Save Data Store"
    }
  ],
  "connections": {
    "BBC RSS": {
      "main": [
        [
          {
            "node": "Tag Source (BBC)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ABC RSS": {
      "main": [
        [
          {
            "node": "Tag Source (ABC)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "TIME RSS": {
      "main": [
        [
          {
            "node": "Tag Source (TIME)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tag Source (BBC)": {
      "main": [
        [
          {
            "node": "Merge BBC+ABC",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tag Source (ABC)": {
      "main": [
        [
          {
            "node": "Merge BBC+ABC",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge BBC+ABC": {
      "main": [
        [
          {
            "node": "Merge All",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tag Source (TIME)": {
      "main": [
        [
          {
            "node": "Merge All",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge All": {
      "main": [
        [
          {
            "node": "Normalize + Dedupe",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize + Dedupe": {
      "main": [
        [
          {
            "node": "Save Data Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cron (10m)": {
      "main": [
        [
          {
            "node": "BBC RSS",
            "type": "main",
            "index": 0
          },
          {
            "node": "ABC RSS",
            "type": "main",
            "index": 0
          },
          {
            "node": "TIME RSS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}