Skip to content
UsecaseBoard
← All use cases
hashnodeDocument Extraction

Extract an emailed invoice PDF into checkable structured data

At a glance

Robert Breen's n8n tutorial turns a text-based invoice attachment into typed fields that can be inspected before further processing. This workflow is listed under Document Extraction, Invoices, Workflow Automation.

Agents / tools
n8n, Gmail, OpenAI Chat Model

SourceBuilding a tool for these workflows? See weekly rates.

What they did

1) Have n8n, Gmail and OpenAI credentials, and a text-based invoice PDF. 2) Add Gmail Trigger, disable Simplify, and enable attachment downloading. Feed attachment_0, the first attachment's binary, to Extract from File with its PDF extraction operation. 3) Connect Information Extractor and an OpenAI Chat Model. Generate the schema from a JSON example with string fields vendor, invoice_number, po_number, invoice_date, due_date; numeric total; and a line_items array containing string item and numeric qty and unit_price. 4) Supply {{ $json.text }} as input. Instruct extraction to preserve printed values, leave absent fields empty, format dates as YYYY-MM-DD, and return amounts without currency formatting. 5) Run the test. Compare the extracted fields under output, including $json.output.total, with the PDF before using them downstream.

Worth knowing

The example invoice is fictional. Image-only scans need OCR before extraction; this reading stage does not approve or pay invoices.

Save ideas in this browser. Upvotes count across the board.

Prompt excerpt

No prompt excerpt was provided by the source.

Sponsored

CodeBuddy

Tencent Cloud AI coding assistant for IDE and CLI.

Try CodeBuddy ↗
Explore all →