{"product_id":"sync-erp-order-to-cash-to-postgres-slack-n8n-sql-server","title":"Sync ERP Order-to-Cash to Postgres \u0026 Slack (n8n, SQL Server)","description":"\u003ch3\u003eSync ERP Order-to-Cash from Microsoft SQL Server into Postgres—then alert Finance in Slack\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow pulls daily open sales orders from your Microsoft SQL Server ERP, normalizes and upserts them into a PostgreSQL data mart, flags credit-risk\/high-value orders, and keeps your team informed with Slack + Gmail run digests—while logging every run (and failures) back to Postgres.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eRuns daily at 06:30 (Berlin)\u003c\/strong\u003e and loads settings such as lookback window, alert thresholds, Slack channel ID, and Gmail digest recipient.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eQueries Microsoft SQL Server\u003c\/strong\u003e for recent open sales orders, aggregating order totals and credit-risk indicators from the ERP.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eNormalizes and deduplicates\u003c\/strong\u003e ERP rows into a canonical order model using order ID to avoid duplicate records.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eCalculates order metrics\u003c\/strong\u003e, including credit utilization and credit-risk status.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eProcesses orders in batches of 100\u003c\/strong\u003e and performs idempotent upserts into PostgreSQL using \u003cem\u003eINSERT…ON CONFLICT\u003c\/em\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eSends Slack alerts\u003c\/strong\u003e for any order flagged as credit risk or exceeding the configured high-value threshold, and logs those events to a PostgreSQL audit table.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eGenerates a daily KPI digest\u003c\/strong\u003e (orders synced, revenue, averages, credit-risk count, and top customers) and builds an HTML summary.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eEmails the digest via Gmail\u003c\/strong\u003e, posts the digest to Slack, and writes a run summary to PostgreSQL.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eHandles errors\u003c\/strong\u003e by formatting an error payload, logging the failure to PostgreSQL, and sending a Slack alert.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eOrder-to-Cash visibility: keep a Postgres data mart continuously aligned with your ERP’s open orders.\u003c\/li\u003e\n  \u003cli\u003eFinance risk monitoring: trigger Slack notifications for credit-risk or high-value orders before issues escalate.\u003c\/li\u003e\n  \u003cli\u003eOperational reporting: daily KPI digests delivered to stakeholders via Slack and Gmail.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eIntegrations: \u003cstrong\u003eMicrosoft SQL Server\u003c\/strong\u003e (ERP read replica), \u003cstrong\u003ePostgreSQL\u003c\/strong\u003e (data mart + audit + run summaries), \u003cstrong\u003eSlack\u003c\/strong\u003e, \u003cstrong\u003eGmail\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003eKey workflow nodes\/tools: \u003cstrong\u003eif\u003c\/strong\u003e, \u003cstrong\u003eset\u003c\/strong\u003e, \u003cstrong\u003ecode\u003c\/strong\u003e, \u003cstrong\u003emerge\u003c\/strong\u003e, \u003cstrong\u003eslack\u003c\/strong\u003e, \u003cstrong\u003egmail\u003c\/strong\u003e.\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":46228891533491,"sku":"N8N-20968","price":72.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/EIUtDvU05Cx3QqDsNAlL0_GhPA2lFx.png?v=1792055647","url":"https:\/\/buyflowscripts.com\/products\/sync-erp-order-to-cash-to-postgres-slack-n8n-sql-server","provider":"N8N Commerce","version":"1.0","type":"link"}