# Detect and correct claims cost leakage with OpenAI: n8n workflow

> Started by a clock, and works across Email and Postgres. It hands the judgement calls to OpenAI.

Source: https://millionrounds.com/workflow/detect-and-correct-claims-cost-leakage-with-openai (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Alerts and monitoring](https://millionrounds.com/workflows?category=Alerts+and+monitoring#library)

# Detect and correct claims cost leakage with OpenAI

Started by a clock, and works across Email and Postgres. It hands the judgement calls to OpenAI. 23 steps, 3 branches: large, and worth reading before you trust it with anything live.

Large Calls a model: OpenAI

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fdetect-and-correct-claims-cost-leakage-with-openai)

**23 steps** Large: read it before trusting it with anything live

**3** Branches: places the flow splits

**0** Loops or waits

**2** Services it connects to

## The flow

Starts it 1 Model 4 Logic 12 Service 6

The steps in the order they run, from what starts it.

- 1 **Daily Claims Analysis Schedule** Schedule trigger *Starts it*
- 2 **OpenAI GPT-4** Lm Chat Open Ai *Model*
- 3 **Classification Output Parser** Output Parser Structured *Model*
- 4 **Calculator Tool** Tool Calculator *Model*
- 5 **Workflow Configuration** Set *Logic*
- 6 **AI Root Cause Classifier** Agent *Model*
- 7 **Fetch Historical Claims Data** Http Request *Service*
- 8 **Generate Corrective Adjustments** Code *Logic*
- 9 **Detect Cost Leakage Anomalies** Code *Logic*
- 10 **Aggregate Findings Report** Aggregate *Logic*
- 11 **Route By Severity** Switch *Logic*
- 12 **Check If Leakage Detected** If *Logic*
- 13 **Send Leakage Report** Email Send *Service*
- 14 **Check If Requires Escalation** If *Logic*
- 15 **Aggregate By Vendor** Aggregate *Logic*
- 16 **Split Anomalies Into Items** Split Out *Logic*
- 17 **No Leakage Found** Set *Logic*
- 18 **Send Escalation Alert** Email Send *Service*
- 19 **Fetch Vendor History** Http Request *Service*
- 20 **Fetch Policy Rules** Http Request *Service*
- 21 **Check Historical Patterns** Postgres *Service*
- 22 **Merge Enrichment Data** Merge *Logic*
- 23 **Calculate Risk Score** Code *Logic*

## How it's built

- **Starts on:** A clock
- **Steps:** 23, with 3 branches
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Email, Postgres
- **Model:** OpenAI

## Questions

What does it need to run?

An n8n account, plus your own Email and Postgres accounts, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on a clock.

Does it use AI?

Yes. It calls OpenAI. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 23 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 23 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fdetect-and-correct-claims-cost-leakage-with-openai)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Email](https://millionrounds.com/workflows?service=Email#library)[Postgres](https://millionrounds.com/workflows?service=Postgres#library)

## Workflows like it

Also alerts and monitoring, with the same services where possible, closest in size first.

- [**Categorize emails & get Telegram alerts with Azure OpenAI** 23 steps · calls a model · Email, Google Sheets](https://millionrounds.com/workflow/categorize-emails-and-get-telegram-alerts-with-azure-openai)
- [**Monitor AI budgets and optimize costs with Claude and Slack** 23 steps · calls a model · Email, Slack](https://millionrounds.com/workflow/monitor-ai-budgets-and-optimize-costs-with-claude-and-slack)
- [**Monitor attack surface changes with OpenAI and Postgres** 23 steps · calls a model · Email, Postgres](https://millionrounds.com/workflow/monitor-attack-surface-changes-with-openai-and-postgres)
- [**Monitor customer risk and AI feedback with PostgreSQL** 23 steps · Discord, Gmail](https://millionrounds.com/workflow/monitor-customer-risk-and-ai-feedback-with-postgresql)
- [**User authentication system with Gmail and Postgres** 23 steps · Gmail, Postgres](https://millionrounds.com/workflow/user-authentication-system-with-gmail-and-postgres)
- [**Analyze contract PDFs and score risk with Claude and Postgres** 22 steps · calls a model · Gmail, Postgres](https://millionrounds.com/workflow/analyze-contract-pdfs-and-score-risk-with-claude-and-postgre)
