Skip to main content

Flag duplicate and risky AP invoices with Gmail, OpenAI and Supabase

Workflow preview

Workflow preview
100%
Flag duplicate and risky AP invoices with Gmail, OpenAI and Supabase preview
Open on n8n.io

1. Workflow Overview

How it works Monitors your AP inbox for incoming invoices, extracts structured data with AI, runs duplicate and vendor history checks against Supabase, then scores each invoice for fraud risk — ...

Best for

  • Invoice Processing automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.gmailtrigger, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.outputparserstructured, n8n-nodes-base.supabase, n8n-nodes-base.code, n8n-nodes-base.if

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Kumar SmartFlow Craft.

Original n8n.io source

1.1 Workflow description

Title
Flag duplicate and risky AP invoices with Gmail, OpenAI and Supabase
Workflow name
Flag duplicate and risky AP invoices with Gmail, OpenAI and Supabase

🚀 How it works

Monitors your AP inbox for incoming invoices, extracts structured data with AI, runs duplicate and vendor history checks against Supabase, then scores each invoice for fraud risk — routing suspicious ones to Slack and your AP team before any payment is processed.

  • 📬 Gmail Trigger monitors your accounts payable inbox in real time
  • 🤖 AI Agent extracts invoice number, vendor, amount, currency, dates and line items into structured JSON — no manual data entry
  • 🔍 Checks Supabase for duplicate invoice numbers already in the system
  • 🏢 Checks vendor payment history — flags unknown vendors and amount deviations above 50% from the vendor's historical average
  • 🧠 Second AI Agent scores fraud risk: low / medium / high / critical with specific fraud indicators and a recommended action
  • 🚨 High/critical risk — posts a detailed Slack alert to #invoice-alerts and emails your AP manager with a hold notice
  • 🗄️ Logs every processed invoice to Supabase with risk score and status

🛠️ Set up steps

Estimated setup time: ~20 minutes

  1. Gmail Trigger — connect Gmail OAuth2; point it at your AP inbox
  2. OpenAI — connect OpenAI API credential (used by both AI Agent nodes)
  3. Supabase — connect Supabase API credential; create two tables: invoices (invoice_number, vendor_name, amount, status, risk_level, created_at) and vendors (vendor_name, avg_amount, total_invoices, flagged)
  4. Slack — connect Slack OAuth2; update the channel name #invoice-alerts
  5. Gmail (Send) — connect Gmail OAuth2; replace [email protected]
  6. Follow the sticky notes inside the workflow for per-node guidance

📋 Prerequisites

  • Gmail account receiving invoices
  • OpenAI API key (GPT-4o)
  • Supabase project with invoices and vendors tables
  • Slack workspace with an alerts channel

Custom Workflow Request with Personal Dashboard

[email protected]

https://www.smartflowcraft.com/contact

More free templates

https://www.smartflowcraft.com/n8n-templates

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 - Overview

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

Block 2 - Prerequisites

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

Block 3 - Setup Required

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

Block 4 - How It Works

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

Block 5 - Gmail — Invoice Inbox

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

Block 6 - Extract note

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

Block 7 - Extract Invoice Data

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.8

Block 8 - OpenAI — Extract

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 9 - Invoice Data Schema

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.2

Block 10 - Duplicates note

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

Block 11 - Check Duplicates

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

Block 12 - Count Dup note

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

Block 13 - Count Duplicates

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

Block 14 - Vendor note

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

Block 15 - Check Vendor History

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

Block 16 - Merge Context note

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

Block 17 - Merge All Context

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

Block 18 - Risk note

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

Block 19 - Assess Fraud Risk

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.8

Block 20 - OpenAI — Risk

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 21 - Fraud Risk Schema

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.2

Block 22 - High Risk note

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

Block 23 - High Risk?

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

Block 24 - Slack note

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

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

3. Summary Table

Workflow Flag duplicate and risky AP invoices with Gmail, OpenAI and Supabase
Complexity advanced
Nodes 28
Categories Invoice Processing, AI Summarization
Author Kumar SmartFlow Craft
Published 18 Mar 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/14146/14146.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 Flag duplicate and risky AP invoices with Gmail, OpenAI and Supabase do?

How it works Monitors your AP inbox for incoming invoices, extracts structured data with AI, runs duplicate and vendor history checks against Supabase, then scores each invoice for fraud risk — ...

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 Invoice Processing, AI Summarization use case.