Automated invoice data extraction with LlamaParse, Gemini 2.5 & Google Sheets
This n8n template demonstrates how to automate invoice data extraction from PDF attachments received via Gmail. Using LlamaParse and Gemini LLM, this workflow parses structured fields like PO numbers, line items, tax ...
Template notes
This n8n template demonstrates how to automate invoice data extraction from PDF attachments received via Gmail. Using LlamaParse and Gemini LLM, this workflow parses structured fields like PO numbers, line items, tax amounts, and totals — and stores them neatly into a Google Sheet.
Perfect for use cases such as: 💼 Finance teams managing vendor invoices 📊 Bookkeeping workflows 🔄 Automating monthly reconciliation
Good to Know At the time of writing, LlamaParse and Gemini may involve API usage costs depending on your subscription tier. Check LlamaIndex Pricing and Gemini Pricing for updated info.
LlamaParse provides Markdown-formatted parsed output which is then passed to an LLM for structured field extraction.
Gemini models may be geo-restricted. If you encounter "model not found" errors, your region might not be supported.
How it Works - Trigger: Watches your Gmail for new emails with PDF attachments. - Email Filter: Ensures we only parse fresh emails not already labeled as "invoice synced". - LlamaParse Upload: Uploads the PDF to LlamaParse’s parsing endpoint. - Status Polling: Periodically checks whether the parsing is complete. - Download Markdown: Once ready, it fetches the parsed invoice in Markdown format. - AI Parsing with Gemini: Sends the Markdown to Gemini LLM to extract structured JSON (like PO number, line items, taxes, etc.) using a predefined schema. - Google Sheets Upload: Stores extracted data into a predefined spreadsheet. - Labeling: Marks the email as “invoice synced” to avoid reprocessing.
How to Use The trigger is based on Gmail, but you can replace this with a webhook or manual trigger for testing.
Setup Instructions Gmail API - Enable Gmail API in Google Cloud Console. - Connect your Gmail account in n8n credentials. - Allow read + modify access.