← All N8N workflows
AI & researchAggregateChain LLMGmailGmail TriggerGoogle Sheets

πŸ™‹β€β™‚οΈ Why not just use the built-in PDF convertor?

Configured with Aggregate, Chain LLM, Gmail, Gmail Trigger, and additional nodes. Review the connections and setup before adapting this template.

Workflow preview
AI & modelsOpenAI ModelLM Open AiTransformStructured OutputParserOutput Parser StructuredWeb / APIUpload to LlamaParseHTTP RequestTriggerReceiving InvoicesGmail TriggerData storeAppend toReconciliation SheetGoogle SheetsWeb / APIGet Processing StatusHTTP RequestWaitWait to stay withinservice limitsWaitRoutingIs Job Ready?SwitchMessagingAdd "invoice synced"LabelGmailWeb / APIGet Parsed Invoice DataHTTP RequestTransformMap OutputEdit FieldsAI & modelsApply Data ExtractionRulesChain LLMRoutingShould Process Email?IfTransformSplit Out LabelsSplit OutMessagingGet Labels NamesGmailTransformCombine Label NamesAggregateTransformEmail with Label NamesMerge

Node categories in this workflow

  • AI & models
  • Transform
  • Web / API
  • Trigger
  • Data store
  • Wait
  • Routing
  • Messaging

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and βˆ’ to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
OpenAI ModelAI & modelsLM Open AiSee node parameters
Structured Output ParserTransformOutput Parser StructuredSee node parameters
Upload to LlamaParseWeb / APIHTTP RequestPOST
Receiving InvoicesTriggerGmail TriggerSee node parameters
Append to Reconciliation SheetData storeGoogle Sheetsappend
Get Processing StatusWeb / APIHTTP RequestSee node parameters
Wait to stay within service limitsWaitWaitSee node parameters
Is Job Ready?RoutingSwitchSee node parameters
Add "invoice synced" LabelMessagingGmailaddLabels
Get Parsed Invoice DataWeb / APIHTTP RequestSee node parameters
Map OutputTransformEdit FieldsSee node parameters
Apply Data Extraction RulesAI & modelsChain LLMSee node parameters
Should Process Email?RoutingIfSee node parameters
Split Out LabelsTransformSplit OutSee node parameters
Get Labels NamesMessagingGmaillabel / get
Combine Label NamesTransformAggregateSee node parameters
Email with Label NamesTransformMergeSee node parameters

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

  • gmailOAuth2
  • googleSheetsOAuth2Api
  • httpHeaderAuth
  • openAiApi

Workflow notes

2. Advanced PDF Processing with LlamaParse

2. Advanced PDF Processing with LlamaParse

Read more about using HTTP Requests

LlamaIndex's LlamaCloud is a cloud-based service that allows you to upload, parse, and index document. LlamaParse is a tool offered by LlamaCloud to parse for complex PDFs with embedded objects ie PDF Tables and figures.

At time of writing, you can parse 1000 pdfs/day with LlamaCloud's free plan by signing up at https://cloud.llamaindex.ai/.

1. Watch for Invoice Emails

1. Watch for Invoice Emails

Read more about Gmail Triggers

The Gmail node can watch for all incoming messages and filter based on a condition. We'll set our Gmail node to wait for:

  • a message from particular email address.
  • having an attachment which should be the invoice PDF
  • not having a label "invoice synced", which is what we use to avoid duplicate processing.
3. Use LLMs to Extract Values from Data

3. Use LLMs to Extract Values from Data

Read more about Basic LLM Chain

Large language models are perfect for data extraction tasks as they can work across a range of document layouts without human intervention. The extracted data can then be sent to a variety of datastores such as spreadsheets, accounting systems and/or CRMs.

Tip: The "Structured Output Parser" ensures the AI output can be inserted to our spreadsheet without additional clean up and/or formatting.

πŸ™‹β€β™‚οΈ Why not just use the built-in PDF convertor?

πŸ™‹β€β™‚οΈ Why not just use the built-in PDF convertor?

A common issue with PDF-to-text convertors are that they ignore important data structures like tables. These structures can be important for data extraction. For example, being able to distinguish between seperate line items in an invoice.

4. Add Label to Avoid Duplication

4. Add Label to Avoid Duplication

Read more about working with Gmail

To finish off the workflow, we'll add the "invoice synced" label to the original invoice email to flag that the extraction was successful. This can be useful if working with a shared inbox and for quality control purposes later.

Try Me Out!

Try Me Out!

This workflow does the following:

  • Waits for email invoices with PDF attachments.
  • Uses the LlamaParse service to convert the invoice PDF into a markdown file.
  • Uses a LLM to extract invoice data from the Markdown file.
  • Exports the extracted data to a Google Sheet.

Follow along with the blog here

https://blog.n8n.io/how-to-extract-data-from-pdf-to-excel-spreadsheet-advance-parsing-with-n8n-io-and-llamaparse/

Good to know

  • You'll need to create the label "invoice synced" in gmail before using this workflow.

Need Help?

Join the Discord or ask in the Forum!

Happy Hacking!

Sticky Note6

Need more attributes? Change it here!

Sticky Note7

🚨Required

  • Set Your Google Sheet URL here
  • Set the Name of your Sheet

Don't use GSheets? Swap this for Excel, Airtable or a Database!

Sticky Note8

🚨Required

  • Change the email filters here!
πŸ™‹β€β™‚οΈ Why not just use the built-in PDF convertor?

πŸ™‹β€β™‚οΈ Why not just use the built-in PDF convertor?

Purpose and structure

This folder contains the πŸ™‹β€β™‚οΈ Why not just use the built-in PDF convertor? workflow. Its executable nodes use aggregate, chainLlm, gmail, gmailTrigger, googleSheets, httpRequest, if, lmOpenAi, merge, outputParserStructured, set, splitOut, switch, wait. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

Receiving Invoices

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Wait/0523_Wait_Splitout_Create_Webhook.json MIT; preserve source notices.

More in AI & research