๐Ÿ“ Sync PostgreSQL changes to SharePoint lists via Microsoft Graph with Teams alerts

โšก 17 views ยท ๐Ÿ“ File Management

Description

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

Customization

๐Ÿ”— Nodes Used

HTTP Request, Postgres, Microsoft Teams, Schedule Trigger

๐Ÿ“ฅ Import

Download workflow.json and import into n8n: Workflow menu โ†’ Import from File

๐Ÿ“– Importing guide ยท ๐Ÿ”‘ Credential setup