You will build an n8n workflow that watches a Gmail inbox, reads PDF invoices, pulls out the key fields with OpenAI, checks for duplicates, logs everything to Google Sheets and posts a note in Slack. It suits anyone comfortable with no-code automation who handles a steady flow of supplier invoices. You need accounts with n8n, OpenAI, Gmail, Google Sheets and Slack.
YouTube video: Build an AI Invoice Processing Agent in n8n | Step-by-Step Tutorial
Caption availability is unknown. Check the CC control in the YouTube player.
- Video length
- 26 min 3 s
- Time to do it
- 45 minutes
- Difficulty
- Medium
- Steps
- 8
What you need
Steps
Create a new workflow in n8n and add a Gmail Trigger node. Connect your Google account, choose the inbox to watch, and set the filter to unread emails that have a PDF attachment.
Add an Extract from File node after the trigger. Set it to read the PDF attachment binary and output plain text, so the invoice content becomes usable data.
Add an OpenAI node and write a system prompt asking for JSON only, with fields for vendor, invoice number, invoice date, currency, total and line items. Turn on JSON output mode.
Add a Google Sheets node set to Get Rows and read your invoice log. Compare the extracted invoice number against the stored column to spot duplicates.
Add an IF node on that comparison. Route new invoice numbers down the true branch and send repeats to a separate branch that only marks the email as processed.
Add an Append Row Google Sheets node on the true branch. Map each extracted field to its matching column so the invoice is logged in one clean row.
Add a Slack node that posts to your finance channel. Include the vendor, total and a short note so the team can approve or query the invoice.
Finish with a Gmail node that adds a label such as Processed or marks the email as read. Save the workflow, run it once on a test invoice, then activate it.
Tips and common mistakes
Test the workflow with two or three real invoices before switching it on, so you catch mapping mistakes early.
Scanned image PDFs return no text, so add an OCR step or ask suppliers for text-based invoices.
Keep your OpenAI and Google credentials in n8n's credential store and never paste API keys into node fields.
Use a strict JSON prompt and a unique invoice number column, otherwise duplicate detection will miss repeats.
Questions
Do I need to know how to code?
No. The whole workflow is built from nodes you configure with dropdowns and field mappings. You only need to write the instruction text for the OpenAI node.
What happens if the AI reads a field wrongly?
The wrong value lands in Google Sheets, so keep a review column or a Slack approval step. Check the first few weeks of entries against the original PDFs.
Can I use Outlook or another inbox instead of Gmail?
Yes. n8n has trigger nodes for other mail providers and for IMAP. Swap the Gmail nodes and keep the rest of the workflow the same.
The notes are drafted automatically from video details and general task knowledge. How the guide was prepared
Report a correction


