πββοΈ 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.
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.
| Node | Category | Type | Operation |
|---|---|---|---|
| OpenAI Model | AI & models | LM Open Ai | See node parameters |
| Structured Output Parser | Transform | Output Parser Structured | See node parameters |
| Upload to LlamaParse | Web / API | HTTP Request | POST |
| Receiving Invoices | Trigger | Gmail Trigger | See node parameters |
| Append to Reconciliation Sheet | Data store | Google Sheets | append |
| Get Processing Status | Web / API | HTTP Request | See node parameters |
| Wait to stay within service limits | Wait | Wait | See node parameters |
| Is Job Ready? | Routing | Switch | See node parameters |
| Add "invoice synced" Label | Messaging | Gmail | addLabels |
| Get Parsed Invoice Data | Web / API | HTTP Request | See node parameters |
| Map Output | Transform | Edit Fields | See node parameters |
| Apply Data Extraction Rules | AI & models | Chain LLM | See node parameters |
| Should Process Email? | Routing | If | See node parameters |
| Split Out Labels | Transform | Split Out | See node parameters |
| Get Labels Names | Messaging | Gmail | label / get |
| Combine Label Names | Transform | Aggregate | See node parameters |
| Email with Label Names | Transform | Merge | See node parameters |
Setup
- Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
- Connect your own credentials through n8nβs credential store. Replace
REPLACE_WITH_*values with your resource identifiers. - Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
- 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
gmailOAuth2googleSheetsOAuth2ApihttpHeaderAuthopenAiApi
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.