← Back/InvoiceFlow
04LIVE

InvoiceFlow

Email arrives. Invoice lands in the ledger. Nobody touches it.

InvoiceFlow — screenshot

Overview

A construction firm was processing 100+ invoices a month by hand — downloading attachments, copying fields into a spreadsheet, renaming files, filing to Drive. I replaced the entire loop with a two-workflow n8n pipeline. Emails are pulled from Gmail, each attachment is classified by Gemini Vision, structured data is extracted, vendor names are normalized, duplicates are caught before they land, files are renamed and moved to the right Drive folder, and the AP team gets clean rows in Google Sheets plus a Gmail label on every email showing exactly where it ended up.

How it works

01
Email Arrives in Gmailtrigger

Main workflow polls Gmail; a sub-workflow spawns per email, then loops per attachment.

02
AI Classificationai

Gemini Flash Lite checks for vendor, invoice number, date, amount, and customer — all five must be present or the file is routed out.

03
Data Extractionai

Gemini Flash extracts structured fields; detects AIA G703/G732 format and switches field-mapping automatically.

04
Vendor Normalizationprocess

Raw vendor string → normalized name → vendor code via two-step lookup; unknowns are auto-appended as stubs for review.

05
Duplicate Detectionprocess

Composite key (Vendor–Project–InvoiceNumber) checked against live Sheets before any write; duplicates flagged, not dropped.

06
Drive Filingstorage

File renamed to Vendor InvoiceNumber convention and moved from Raw Attachments to the Invoices folder in Drive.

07
Sheets Row + Gmail Labeloutput

Clean row written to Google Sheets; Gmail label set to Processed, NeedsReview, or NoInvoice — instant visual triage.

Results

100+
Invoices / month
0
Manual touches
7
Automated steps
100%
Audit trail

Pipeline

01
Gmail
Email trigger
02
Classify
Gemini Flash Lite
03
Extract
Gemini Flash
04
Normalize
Vendor lookup
05
Dedupe
Composite key
Drive
File renamed + filed
Sheets
Row written
Label
Gmail triage

What was built

01

Two-workflow architecture — a main email loop triggers a sub-workflow per email, which loops again per attachment; handles any number of attachments in a single message without manual intervention.

02

AI classification with strict criteria — Gemini Flash Lite checks each file: vendor, invoice number, date, amount, and customer must all be present. Statements, receipts, quotes, and unsupported file types are routed out before extraction runs.

03

Document-type-aware extraction — Gemini Flash detects AIA G703/G732 construction payment application format and switches to a different field-mapping table automatically; all other invoices use standard extraction rules.

04

Vendor normalization + code resolution — two-step lookup: raw vendor string → normalized name (VendorNormalization sheet), then normalized name → vendor code (VendorCodes sheet). Unknown vendors are auto-appended as stubs for manual review.

05

Duplicate detection before write — a composite DuplicateKey (Vendor – Project – InvoiceNumber) is checked against the live Invoices sheet; flagged duplicates still land in the sheet but carry DuplicateFlag: true so the AP team can decide.

06

File lifecycle management — every attachment lands in Raw Attachments on upload, gets renamed to the 'Vendor InvoiceNumber' convention, and moves to the Invoices Drive folder. Files that fail classification stay in raw storage.

07

Gmail label pipeline — each email transitions from Invoices/Processing to Invoices/Processed, Invoices/NeedsReview, or Invoices/NoInvoice, giving the AP team instant visual triage without opening Sheets.

Client Feedback

We had a great experience working with Tayyub on an AI automation project. He quickly understood our business requirements, asked thoughtful clarifying questions, and translated our objectives into a clean, scalable solution. The project involved automating a multi-step workflow with several integrations, and they handled it with strong technical skill and attention to detail. What stood out most was their ability to think beyond just "making it work." They structured the automation in a way that is maintainable, well-documented, and easy for our team to manage going forward. Would absolutely hire again and highly recommend to anyone looking for a reliable AI automation expert who delivers real business impact.

Peyton Vitter · Upwork

Role

Sole engineer · end-to-end n8n build.

Stack

n8nGoogle Gemini FlashGoogle Gemini Flash LiteGmail APIGoogle DriveGoogle Sheets