{"product_id":"n8n-workflow-detect-subscription-revenue-anomalies-with-postgres-claude","title":"n8n Workflow: Detect Subscription Revenue Anomalies with Postgres \u0026 Claude","description":"\u003ch3\u003eSpot subscription revenue anomalies automatically—with Postgres + Claude\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow detects unusual subscription revenue drops or surges by analyzing daily metrics in Postgres, investigating likely causes (including an Anthropic Claude root-cause analysis), and alerting you via Slack and PagerDuty when it matters.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eRuns on schedule, webhook, or manual trigger\u003c\/strong\u003e: executes daily via cron, a POST webhook (optionally accepting a \u003cem\u003etargetDate\u003c\/em\u003e override), or manually.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eSets up and uses Postgres for baselines\u003c\/strong\u003e: creates\/ensures tables for metric history, anomaly records, and run tracking; loads recent history and prior anomalies for deduplication.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003ePulls subscription and payment data from external HTTP APIs\u003c\/strong\u003e: normalizes subscription events, payment records, and optional business context; fails fast with a logged failed run if required billing feeds are unavailable.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eBuilds weekday-aware daily metrics\u003c\/strong\u003e: calculates series overall and segmented by plan\/country\/channel; performs data-quality gap checks before analysis.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eDetects statistically unusual points and sustained shifts\u003c\/strong\u003e: uses robust, weekday-aware baselines to flag revenue anomalies.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eInvestigates likely causes\u003c\/strong\u003e: drills into contributing segments, correlates with business events, analyzes payment failure codes, and checks for single-customer concentration.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eGenerates a root-cause narrative with Anthropic Claude\u003c\/strong\u003e: for medium-or-higher investigated anomalies, sends an evidence pack to Claude with guard rails that only allow severity downgrades.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eAlerts the right teams\u003c\/strong\u003e: sends notifications via Slack and PagerDuty for actionable visibility.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eDetecting sudden MRR\/ARR changes driven by subscription events, billing failures, or regional\/plan-specific behavior.\u003c\/li\u003e\n  \u003cli\u003ePreventing alert fatigue by deduplicating anomaly runs using Postgres history.\u003c\/li\u003e\n  \u003cli\u003eProviding faster incident triage for SaaS operators when revenue metrics deviate from expected weekday patterns.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003en8n nodes \/ patterns:\u003c\/strong\u003e if, code, no op, merge, webhook, postgres\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eCore systems:\u003c\/strong\u003e Postgres for metric history + anomaly persistence; Anthropic Claude for root-cause generation; Slack and PagerDuty for alerts\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eData pipeline:\u003c\/strong\u003e scheduled\/triggered runs, external HTTP API fetch + normalization, anomaly storage and run tracking\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":46275710025907,"sku":"N8N-21229","price":43.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/Gdw0gLbysnkra6SCkMChw_NwBN8EaU.png?v=1792833833","url":"https:\/\/buyflowscripts.com\/products\/n8n-workflow-detect-subscription-revenue-anomalies-with-postgres-claude","provider":"N8N Commerce","version":"1.0","type":"link"}