Skip to main content

Sync PostgreSQL changes to SharePoint lists via Microsoft Graph with Teams alerts

Workflow preview

Workflow preview
100%
Sync PostgreSQL changes to SharePoint lists via Microsoft Graph with Teams alerts preview
Open on n8n.io

1. Workflow Overview

Quick overview This workflow runs every 15 minutes and uses a watermark to incrementally sync recently updated rows from PostgreSQL to a Microsoft SharePoint list via the Microsoft Graph $batch API...

Best for

  • File Management automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.scheduletrigger, n8n-nodes-base.set, n8n-nodes-base.code, n8n-nodes-base.postgres, n8n-nodes-base.if, n8n-nodes-base.splitinbatches, n8n-nodes-base.httprequest

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Mychel Garzon.

Original n8n.io source

1.1 Workflow description

Title
Sync PostgreSQL changes to SharePoint lists via Microsoft Graph with Teams alerts
Workflow name
Sync PostgreSQL changes to SharePoint lists via Microsoft Graph with Teams alerts

Quick overview

This workflow runs every 15 minutes and uses a watermark to incrementally sync recently updated rows from PostgreSQL to a Microsoft SharePoint list via the Microsoft Graph $batch API, posting run summaries and deduplicated error alerts to a Microsoft Teams channel.

How it works

  1. Runs every 15 minutes on a schedule and loads SharePoint/Teams configuration plus the last successful sync timestamp stored in n8n static data.
  2. Queries PostgreSQL for rows updated since the last watermark timestamp and aggregates the results into a single batchable payload.
  3. If no rows are returned, advances the watermark to the current run start time and posts a sync summary to Microsoft Teams.
  4. If rows exist, chunks them into Graph-compliant $batch requests (max 20 operations per batch) that create items in the target SharePoint list.
  5. Sends each batch to the Microsoft Graph $batch endpoint with retries and classifies per-item results into successes, failures, and 429 throttling.
  6. Aggregates results across all batches and, when new failures appear, posts a Microsoft Teams alert listing the failed/throttled source IDs while suppressing repeat alerts for previously seen IDs.
  7. Updates the stored watermark only when there are zero failures, then posts a Microsoft Teams sync summary with counts and watermark status.

Setup

  1. Add a PostgreSQL credential, then update the SQL query to use your table name and an indexed updated_at timestamptz column.
  2. Add a Microsoft Graph OAuth2 credential with permissions to create SharePoint list items, and set your SharePoint site ID and list ID in the workflow configuration values.
  3. Edit the field mapping used for SharePoint list item creation so your PostgreSQL columns map to your SharePoint field internal names.
  4. Add Microsoft Teams credentials and set the target Team ID and Channel ID for both the sync summary and error alert messages.

Requirements

  • PostgreSQL database with an indexed updated_at timestamptz column on the source table
  • Microsoft Graph OAuth2 credential with Sites.ReadWrite.All permission for the target SharePoint site
  • Microsoft SharePoint list with field internal names matching the column mapping in the batch payload builder
  • Microsoft Teams credential with permission to post to the configured team and channel

Customization

  • Change the polling interval in the Every 15 Minutes Trigger node to run more or less frequently depending on your data update volume.
  • Adjust the batchSize value in the Set Configuration Parameters node — the maximum is 20 per Graph API constraint and is enforced in code regardless of what is set here.
  • Modify the SQL query in the Query Updated Rows from Postgres node to add filters, joins, or column selections beyond the default updated_at watermark check.
  • Extend the batch payload builder in the Construct Graph Batch Payloads node to support upsert logic by adding a dependsOn field to chain an existence-check request before each write.
  • Add a dead-letter table in PostgreSQL and exclude persistently failing rows from the query using AND id NOT IN (SELECT id FROM sync_dead_letter) to break infinite retry cycles.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 2 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - Sticky Note7

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 9 - Sticky Note8

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 10 - Every 15 Minutes Trigger

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 11 - Set Configuration Parameters

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 12 - Fetch Last Run Timestamp

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 13 - Query Updated Rows from Postgres

Type / Role
n8n-nodes-base.postgres - postgres
Config choices
Version 2.5

Block 14 - Aggregate Postgres Results

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 15 - Check Rows to Sync

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 16 - Update Timestamp No Rows

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 17 - Construct Graph Batch Payloads

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 18 - Loop Over Batch Payloads

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 19 - Post Batch to Graph API

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 20 - Verify Batch API Response

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 21 - Prepare Next Batch

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 22 - Process Looped Results

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 23 - Check for Errors in Run

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 24 - Remove Duplicate Alerts

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Showing the first 24 of 28 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Sync PostgreSQL changes to SharePoint lists via Microsoft Graph with Teams alerts
Complexity advanced
Nodes 28
Categories File Management
Author Mychel Garzon
Published 03 Jun 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/16106/16106.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Sync PostgreSQL changes to SharePoint lists via Microsoft Graph with Teams alerts do?

Quick overview This workflow runs every 15 minutes and uses a watermark to incrementally sync recently updated rows from PostgreSQL to a Microsoft SharePoint list via the Microsoft Graph $batch API...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your File Management use case.