{
  "name": "RSS to file",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * *"
            }
          ]
        }
      },
      "id": "bf354370-7cb0-4a6c-bd8c-2f144cd8a30c",
      "name": "Every morning",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.4,
      "position": [
        -800,
        0
      ]
    },
    {
      "parameters": {
        "url": "https://blog.n8n.io/rss/"
      },
      "id": "cd5ee8f8-e212-4f83-9d11-91cf40cf3afd",
      "name": "Read n8n blog",
      "type": "n8n-nodes-base.rssFeedRead",
      "typeVersion": 1.2,
      "position": [
        -560,
        0
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// Keep only feed items not seen in an earlier run.\n// Seen links live in the workflow's static data, which n8n saves after each run.\nconst staticData = $getWorkflowStaticData('global');\nstaticData.seen = staticData.seen || [];\nconst seen = new Set(staticData.seen);\nconst fresh = [];\nfor (const item of $input.all()) {\n  const key = item.json.guid || item.json.link;\n  if (key && !seen.has(key)) {\n    seen.add(key);\n    fresh.push(item);\n  }\n}\nstaticData.seen = [...seen];\nreturn fresh;"
      },
      "id": "6ea58c40-8380-4f0a-b104-b5f35bf104fa",
      "name": "Keep only new items",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -320,
        0
      ]
    },
    {
      "parameters": {
        "mode": "manual",
        "assignments": {
          "assignments": [
            {
              "id": "5e121305-296f-46de-bb27-c908d5d2e9ab",
              "name": "title",
              "type": "string",
              "value": "={{ $json.title }}"
            },
            {
              "id": "d7749a5c-1a5c-4969-8fd2-d639a0ecab21",
              "name": "link",
              "type": "string",
              "value": "={{ $json.link }}"
            },
            {
              "id": "7cd707c8-0186-4105-bc1a-0d30ba177d0f",
              "name": "pubDate",
              "type": "string",
              "value": "={{ $json.pubDate }}"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      },
      "id": "b54b1a4e-cdc8-40ba-9f09-f103b9d7dac8",
      "name": "Pick fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [
        -80,
        0
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// One CSV line per item, quoted where needed, ending with a newline.\n// Convert to File's CSV mode adds a byte-order mark per chunk and no trailing\n// newline, so a hand-built line is the reliable way to append rows.\nconst esc = (v) => {\n  const s = String(v ?? '');\n  return /[\",\\n]/.test(s) ? '\"' + s.replace(/\"/g, '\"\"') + '\"' : s;\n};\nconst lines = $input.all().map(({ json }) =>\n  [json.title, json.link, json.pubDate].map(esc).join(','),\n);\nreturn [{ json: { line: lines.join('\\n') + '\\n' } }];"
      },
      "id": "281e36c9-d48c-4a4c-9f61-6a5fee3892da",
      "name": "Build CSV lines",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        160,
        0
      ]
    },
    {
      "parameters": {
        "operation": "toText",
        "sourceProperty": "line",
        "binaryPropertyName": "data",
        "options": {
          "addBOM": false,
          "fileName": "n8n-posts.csv"
        }
      },
      "id": "361d4d84-4dc7-4364-9bed-734e0e4a9ddd",
      "name": "To text file",
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.2,
      "position": [
        400,
        0
      ]
    },
    {
      "parameters": {
        "operation": "write",
        "fileName": "/home/hatch/.n8n-files/n8n-posts.csv",
        "dataPropertyName": "data",
        "options": {
          "append": true
        }
      },
      "id": "f165a5d6-3a23-4bff-9193-98d3fbd87c77",
      "name": "Append to file",
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1.1,
      "position": [
        640,
        0
      ]
    }
  ],
  "connections": {
    "Every morning": {
      "main": [
        [
          {
            "node": "Read n8n blog",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read n8n blog": {
      "main": [
        [
          {
            "node": "Keep only new items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep only new items": {
      "main": [
        [
          {
            "node": "Pick fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pick fields": {
      "main": [
        [
          {
            "node": "Build CSV lines",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build CSV lines": {
      "main": [
        [
          {
            "node": "To text file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "To text file": {
      "main": [
        [
          {
            "node": "Append to file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}