{
  "name": "Automated document sync between SharePoint and Google Drive with Supabase",
  "nodes": [
    {
      "id": "2942a203-e59b-4e7e-817d-002885bcd5e5",
      "name": "Loop Over Items2",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -320,
        400
      ]
    },
    {
      "id": "52071823-1ab8-41c1-a44c-8d05f18f270f",
      "name": "Microsoft SharePoint HTTP Request1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        640,
        432
      ]
    },
    {
      "id": "8976ad9b-14fc-408b-b995-e4e7bc9cd702",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1360,
        320
      ]
    },
    {
      "id": "dae4c9ed-2fa1-43b9-8c96-baacef092b02",
      "name": "Compare Datasets",
      "type": "n8n-nodes-base.compareDatasets",
      "position": [
        -592,
        240
      ]
    },
    {
      "id": "24e543d1-2def-405c-9d59-e3cbd80e87df",
      "name": "Supabase",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -1056,
        160
      ]
    },
    {
      "id": "7109b99e-02a9-4b64-b030-71025f6d761c",
      "name": "Supabase1",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -128,
        96
      ]
    },
    {
      "id": "0fcdc702-66e6-4808-80cf-db3559acd2a2",
      "name": "Insert Document Metadata",
      "type": "n8n-nodes-base.postgres",
      "position": [
        384,
        432
      ]
    },
    {
      "id": "d5d5967d-11e3-4152-9c60-266afd1ef6be",
      "name": "Postgres",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1488,
        416
      ]
    },
    {
      "id": "d89ee62e-023a-4437-8fd5-6ab82de340dc",
      "name": "Upload file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1200,
        416
      ]
    },
    {
      "id": "ede831b8-8846-4e13-9085-6d8027be9807",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2000,
        64
      ],
      "parameters": {
        "width": 512,
        "height": 496,
        "content": "#  SharePoint Sync Overview\n\n## How it works\nRuns on a schedule, fetches SharePoint folders and files, filters unwanted formats, and syncs metadata into a Postgres/Supabase table.  \nOnly new or modifi"
      }
    },
    {
      "id": "946a98ba-2286-4f7c-a565-d54daf60db54",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        320
      ],
      "parameters": {
        "width": 176,
        "height": 240,
        "content": "## extract metadata"
      }
    },
    {
      "id": "36db62ed-0b95-4ef7-bb5a-30c57cfe3ca4",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        224
      ],
      "parameters": {
        "width": null,
        "height": 336,
        "content": "## Rename Files\nRenames each downloaded binary file  \nwith its corresponding SharePoint file title before upload.\n"
      }
    },
    {
      "id": "fad59bd5-92b6-4b2e-9577-9dfdaf215684",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1392,
        240
      ],
      "parameters": {
        "width": null,
        "height": 320,
        "content": "## Postgres (Mark Complete)\nMarks entries as processed by setting `Loading Done = true`  \nonce uploads are complete.\n"
      }
    },
    {
      "id": "df5061b7-8935-4875-8e76-625994482128",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1120,
        224
      ],
      "parameters": {
        "width": null,
        "height": 336,
        "content": "## Upload file (Google Drive)\nUploads downloaded files to Google Drive for safe storage or cross-system access.\n"
      }
    },
    {
      "id": "080ef3bd-a31e-408b-958e-d1f47dbddec5",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        576,
        224
      ],
      "parameters": {
        "width": 262,
        "height": 352,
        "content": "## Microsoft SharePoint HTTP Request1 (Download)\nDownloads each new or updated file directly from SharePoint using its `ServerRelativeUrl`.\n"
      }
    },
    {
      "id": "f6649b09-f542-42e1-acfe-7ed1b147de0f",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        336,
        224
      ],
      "parameters": {
        "width": 224,
        "height": 352,
        "content": "## Insert Document Metadata\nUpserts processed SharePoint file data into `n8n_metadata` (Postgres/Supabase).  \nCreates or updates existing records.\n"
      }
    },
    {
      "id": "4cdb293d-9ca2-49e1-be0e-3053c8e758bb",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        16
      ],
      "parameters": {
        "width": null,
        "height": 240,
        "content": "### delete file from supabase (metadata table)"
      }
    },
    {
      "id": "e9c869ff-d7b3-4884-8b76-f65f97a27e04",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        336
      ],
      "parameters": {
        "width": 192,
        "height": 400,
        "content": "## Filter Files\nFilters out system and temporary files (`~$`, `.db`, `.msg`, `.xlsx`, `.pptx`)  \nand flattens nested folders into a single clean file list.\n"
      }
    },
    {
      "id": "0995c238-776e-49b6-9a1f-3ecde5269b87",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        112
      ],
      "parameters": {
        "width": null,
        "height": 336,
        "content": "## Compare Datasets\nCompares SharePoint and Supabase data  \nto detect new or updated files and flag records for processing.\n"
      }
    },
    {
      "id": "b76d59ef-e870-4835-80e2-b402ce313375",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1136,
        336
      ],
      "parameters": {
        "width": null,
        "height": 400,
        "content": "## Microsoft SharePoint HTTP Request\nRetrieves all folders and files recursively from the specified SharePoint document path.\n"
      }
    },
    {
      "id": "352884ed-4bf4-414f-9272-ab689614f9d6",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        16
      ],
      "parameters": {
        "width": null,
        "height": 288,
        "content": "## Supabase (Get)\nRetrieves existing records from `n8n_metadata`  \nto check which SharePoint files are already stored.\n"
      }
    },
    {
      "id": "8c0bfdeb-23b8-45fe-9fdc-0ab4cdf28706",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1408,
        208
      ],
      "parameters": {
        "width": null,
        "height": 256,
        "content": "## Schedule Trigger\nTriggers the workflow on a defined schedule \n"
      }
    },
    {
      "id": "7cb642b1-049c-4379-a672-061d6bf5e38c",
      "name": "Microsoft SharePoint HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1072,
        544
      ]
    },
    {
      "id": "1c967ff9-05de-46c9-9e79-1b5e558871da",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -864,
        16
      ],
      "parameters": {
        "width": 160,
        "height": 288,
        "content": "### standardizes \n`Last_modified_date` "
      }
    },
    {
      "id": "69d5f0d5-3a18-4430-a6a2-a8d1e8c70fbc",
      "name": "filter files",
      "type": "n8n-nodes-base.code",
      "position": [
        -832,
        544
      ]
    },
    {
      "id": "c15798ab-a2eb-457c-a6cb-8471ab4427be",
      "name": "normalize last modified date",
      "type": "n8n-nodes-base.set",
      "position": [
        -832,
        160
      ]
    },
    {
      "id": "2530cd81-1586-4fdb-bafb-5df0723f6d26",
      "name": "get metadata",
      "type": "n8n-nodes-base.code",
      "position": [
        -48,
        432
      ]
    },
    {
      "id": "bc244e21-105c-4cc1-8ef9-f97965abfe90",
      "name": "Set metadata",
      "type": "n8n-nodes-base.set",
      "position": [
        176,
        432
      ]
    },
    {
      "id": "e5935403-cf3a-4ee7-9b1a-d1b8b24f9c35",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        304
      ],
      "parameters": {
        "width": null,
        "height": 256,
        "content": "### loop over newly added or modified files"
      }
    },
    {
      "id": "118eacaa-e244-48d9-8b7d-5bbff742a63a",
      "name": "rename files",
      "type": "n8n-nodes-base.code",
      "position": [
        928,
        416
      ]
    }
  ],
  "connections": {
    "Postgres": {
      "main": [
        [
          {
            "node": "Loop Over Items2",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Supabase": {
      "main": [
        [
          {
            "node": "normalize last modified date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase1": {
      "main": [
        []
      ]
    },
    "Upload file": {
      "main": [
        [
          {
            "node": "Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set metadata": {
      "main": [
        [
          {
            "node": "Insert Document Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "filter files": {
      "main": [
        [
          {
            "node": "Compare Datasets",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "get metadata": {
      "main": [
        [
          {
            "node": "Set metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "rename files": {
      "main": [
        [
          {
            "node": "Upload file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compare Datasets": {
      "main": [
        [
          {
            "node": "Supabase1",
            "type": "main",
            "index": 0
          }
        ],
        [],
        [],
        [
          {
            "node": "Loop Over Items2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items2": {
      "main": [
        [],
        [
          {
            "node": "get metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Supabase",
            "type": "main",
            "index": 0
          },
          {
            "node": "Microsoft SharePoint HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Document Metadata": {
      "main": [
        [
          {
            "node": "Microsoft SharePoint HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "normalize last modified date": {
      "main": [
        [
          {
            "node": "Compare Datasets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Microsoft SharePoint HTTP Request": {
      "main": [
        [
          {
            "node": "filter files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Microsoft SharePoint HTTP Request1": {
      "main": [
        [
          {
            "node": "rename files",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}