Back to Templates

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

Last update

Last update a month ago

Share


๐Ÿš€ 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