<aside> 💡

A bilingual invoice-intake demonstration built with n8n and Google Gemini. It extracts invoice data, checks arithmetic and duplicate submissions, and records new invoices for review.

</aside>

n8n · Google Gemini AI · JavaScript · JSON · n8n Data Tables

GitHub repository · English README · Arabic README / الوثائق العربية · Watch the 50-second walkthrough

Business Challenge

Invoices arrive as PDFs and images, sometimes mixing Arabic and English. Reading supplier details and line items, checking totals and tax, identifying repeat submissions, and maintaining a register can involve repetitive manual work and opportunities for error.

Solution Overview

This portfolio demonstration automates the initial intake, extraction and checking stages. An n8n form receives one invoice; Google Gemini extracts structured information; deterministic JavaScript checks the arithmetic; and the main workflow checks the register before saving a new record for review. It is a demonstration, not a production accounting system.

Workflow Architecture

1. Main Invoice Processing Workflow receives a PDF, JPG/JPEG or PNG through an n8n form and checks the extension, claimed MIME type and 10 MiB size limit. Valid files are sent to the extraction sub-workflow. Returned data is checked for arithmetic and invoice identity, then compared against the registry using a normalized supplier-name and invoice-number key. A new record is saved with pending_review status; distinct messages handle outcomes including duplicates, missing identity, invalid files and AI failure.

2. AI Extraction Engine Sub-workflow handles the document and calls a primary Google Gemini configuration. When extraction or parsing fails, retry and backup routing use a second Gemini configuration. Structured results return to the main workflow; failure of the extraction paths produces an error outcome. Both configurations use the same provider.

Main invoice processing workflow

Main invoice processing workflow

AI extraction engine sub-workflow

AI extraction engine sub-workflow

Key Features

An arithmetic passed result is not proof of authenticity, tax compliance, purchase-order matching or approval.