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

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

Needs changes

by Kumar SmartFlow Craft ✓ · 50 views · created 2026-03-18 · Invoice Processing, AI Summarization

Needs changes. This template uses 1 thing(s) that n8n 3.0 removes: AI Agent v1 (old agent modes). 1 breaking item(s) found. Static check, last run 2026-10-19.

What this workflow does

This AI workflow has 15 nodes and runs on Gmail events. Along the way it connects Gmail, OpenAI Chat Model, Supabase and Slack.

How it runs

Trigger: On Gmail events.

  1. Extract Invoice Data (AI Agent): runs an AI agent, with model: OpenAI — Extract; output parser: Invoice Data Schema
  2. Check Duplicates (Supabase): get many
  3. Count Duplicates (Code): runs custom JavaScript code
  4. Check Vendor History (Supabase): get many
  5. Merge All Context (Code): runs custom JavaScript code
  6. Assess Fraud Risk (AI Agent): runs an AI agent, with model: OpenAI — Risk; output parser: Fraud Risk Schema
  7. High Risk? (If): checks a condition and branches into true / false
  8. Alert Slack (Slack): uses Slack
  9. Log Invoice to Supabase (Supabase): insert
  10. Send Hold Notice (Gmail): uses Gmail

Services it uses

GmailOpenAI Chat ModelSupabaseSlack

Before you upgrade to n8n 3.0

1 thing in this workflow is removed in n8n 3.0. Fix it before you upgrade:

  • AI Agent v1 (old agent modes) in Extract Invoice Data (v1.8), Assess Fraud Risk (v1.8): replace with Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.
  • Also check Gmail Trigger below v1.4 runs as v1.4 (drafts skipped, max emails per poll).
Removed in 3.0Replace with
AI Agent v1 (old agent modes)
Extract Invoice Data (v1.8), Assess Fraud Risk (v1.8)
Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.

Nodes used (9)

From the author

🚀 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…

Excerpt from Kumar SmartFlow Craft's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.