{
  "name": "Salesforce to S3 file migration & cleanup",
  "nodes": [
    {
      "id": "aa8bd0f6-7e04-4036-be3d-7f43e5e4991b",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -900,
        -760
      ]
    },
    {
      "id": "e4a7b64d-6456-4513-8589-67556f02e525",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        -540
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "9f084b45-0fe1-4f0d-bb56-ea44f8c67c3c",
      "name": "Loop Over Each File Record",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -460,
        -765
      ]
    },
    {
      "id": "ed2f0e0e-972b-4b63-afad-81977286edab",
      "name": "Download File Content",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -240,
        -840
      ]
    },
    {
      "id": "d9208cc6-b6ce-4622-8286-096f937239b7",
      "name": "Upload to S3",
      "type": "n8n-nodes-base.awsS3",
      "position": [
        -20,
        -840
      ]
    },
    {
      "id": "bd48b8ba-6938-4a5d-8835-9c7af091af2e",
      "name": "Get LinkedEntityId from ContentDocumentLink",
      "type": "n8n-nodes-base.salesforce",
      "position": [
        200,
        -840
      ]
    },
    {
      "id": "90a3c105-8be3-4df2-b9d7-ac46ab20a9f2",
      "name": "Filter Out User Attachments",
      "type": "n8n-nodes-base.code",
      "position": [
        420,
        -840
      ]
    },
    {
      "id": "63c6798f-1e5f-40db-a950-c3f9652395c3",
      "name": "Create S3_File__c Record",
      "type": "n8n-nodes-base.salesforce",
      "position": [
        640,
        -840
      ]
    },
    {
      "id": "e94a12c8-259a-4316-8e4e-5d7d9360cf55",
      "name": "Prepare ContentDocumentId for Deletion",
      "type": "n8n-nodes-base.code",
      "position": [
        860,
        -840
      ]
    },
    {
      "id": "c72330d0-f318-44e7-9ce3-14e7729ae1f9",
      "name": "Delete Original File in Salesforce",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1120,
        -840
      ]
    },
    {
      "id": "2243b0b4-e417-4bef-8f93-db6b44824c78",
      "name": "Send Slack Notification",
      "type": "n8n-nodes-base.slack",
      "position": [
        -240,
        -640
      ]
    },
    {
      "id": "ba723f66-26d1-42aa-8cc4-e4fc7fd4300d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        -1020
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "0e467508-4f89-45cd-aad2-0968a60ef0c0",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -1120
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "509c7c42-44a3-445d-bcab-95d8594b62b2",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        -1020
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "2883bee3-098a-44c5-ae51-eb06c2d9c2ec",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        -1120
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "648e9af5-0f80-4fe5-80f9-2fafcf0dac8d",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        -1140
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "7063e250-8a74-4af2-bdc5-80f0802f0021",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -1180
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "a6cf774a-5042-4058-8699-674a8252f200",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        -1180
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "9c28a0ef-2a38-47de-9311-68bc986046ac",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        600,
        -1140
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "a2c41a97-d84c-4008-9c02-5908f8cf8dbc",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        -1080
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "5f16310f-30c4-4f7a-b537-a9e8961fda8d",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        -1080
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "e61a28d8-6c62-479e-8991-1f60ed6ec7b9",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        -460
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "4915760a-e9b0-4c3f-bad4-2247fbfa208b",
      "name": "Get All ContentDocuments older than 365 days ago",
      "type": "n8n-nodes-base.salesforce",
      "position": [
        -680,
        -760
      ]
    }
  ],
  "connections": {
    "Upload to S3": {
      "main": [
        [
          {
            "node": "Get LinkedEntityId from ContentDocumentLink",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get All ContentDocuments older than 365 days ago",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File Content": {
      "main": [
        [
          {
            "node": "Upload to S3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create S3_File__c Record": {
      "main": [
        [
          {
            "node": "Prepare ContentDocumentId for Deletion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Each File Record": {
      "main": [
        [
          {
            "node": "Send Slack Notification",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download File Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Out User Attachments": {
      "main": [
        [
          {
            "node": "Create S3_File__c Record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete Original File in Salesforce": {
      "main": [
        [
          {
            "node": "Loop Over Each File Record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare ContentDocumentId for Deletion": {
      "main": [
        [
          {
            "node": "Delete Original File in Salesforce",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get LinkedEntityId from ContentDocumentLink": {
      "main": [
        [
          {
            "node": "Filter Out User Attachments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All ContentDocuments older than 365 days ago": {
      "main": [
        [
          {
            "node": "Loop Over Each File Record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}