Automated Invoice Processing and Verification Using Azure GPT-4.1 - n8n Workflow

Automate invoice processing with this n8n workflow. Uses Gmail as the n8n trigger, analyzes PDF attachments with Azure GPT-4.1, and includes human verification steps before saving files locally.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Accounting departments seeking automated AP (Accounts Payable) processing.
Businesses receiving invoices via email who need reliable classification.
Users looking for advanced n8n templates integrating AI and local file operations.
Finance teams requiring human verification steps in their automated n8n workflow.

Overview

Handling incoming invoices is a critical, yet repetitive, accounting task. This powerful n8n workflow solves the challenge of manual verification and saving by leveraging artificial intelligence and robust flow control. The system automatically monitors a specific Gmail inbox using a dedicated n8n trigger. When an email containing a potential invoice PDF arrives, the n8n node for AI analysis uses Azure OpenAI's GPT-4.1 model to confirm the document's nature. This not only streamlines processing but also introduces a safety net: if the AI struggles or denies the document is an invoice, the n8n workflow automatically initiates a human approval loop via email. This combination of an efficient n8n trigger and intelligent classification drastically reduces manual effort and speeds up invoice approval cycles, making this one of the essential n8n templates for modern finance teams.

How it Works

This comprehensive n8n workflow begins when the Gmail Trigger n8n node detects a new email matching specific sender criteria and downloading attachments. This node acts as the starting n8n trigger.


  1. Initial Filtering: The workflow first checks if the email subject contains "Invoice" and verifies the presence of a binary PDF attachment using an IF n8n node. If these conditions fail, the process is routed to the Error Handler n8n node.

  2. AI Classification: If validated, the data is passed to the LangChain Information Extractor n8n node, which utilizes the connected Azure OpenAI Chat Model (GPT-4.1). The AI is prompted to strictly answer "Yes" or "No" regarding whether the attachment text is an invoice.

  3. Decision Point: An IF n8n node (IF: AI Says Yes) checks the AI’s response.

Success Path: If the AI response is "Yes" (meaning it's verified), the flow proceeds to the Merge n8n node.
Verification Path: If the AI response is "No," the workflow is routed to the Manual Verification n8n node, requiring a human user to review the document.

  1. Local Storage: Once confirmation is received via the Merge node, the workflow reaches the Save PDF Locally n8n node, writing the PDF attachment to a pre-defined local directory path, ensuring unique, timestamped file names.

  2. Completion: Finally, a confirmation email is sent via the Invoice Saved Message n8n node, notifying the user that the invoice has been successfully saved to the local folder. This complete n8n workflow provides end-to-end automation.

Installation Guide

To use this advanced n8n workflow, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON code and import it directly into your n8n instance via the Workflows sidebar using the "New" > "Import from JSON" option.

  2. Set Up Credentials: This n8n workflow requires a Gmail OAuth2 credential for both the Gmail Trigger and the various Gmail send/verification nodes, and an Azure Open AI account credential, linking your n8n instance to your Azure deployment (using the specified gpt-4.1 model).

  3. Update Trigger Parameters: In the Gmail Trigger n8n node, update the sender filter to match the email address you expect invoices from.

  4. Configure Local Saving: Update the file path parameter (C:\Test\Invoices\...) in the Save PDF Locally n8n node to a valid directory on the machine running your n8n instance.

  5. Update Recipients: Ensure the sendTo email addresses in the Manual Verification and Invoice Saved Message n8n node steps are correct for internal communication.

Node Details

Gmail Trigger (n8n trigger): Starts the n8n workflow when an email arrives from a specific sender, automatically downloading attachments for processing.
Is this PDF? (IF n8n node): Checks for two conditions: the subject must contain "Invoice" and a binary attachment (attachment_0) must be present.
Azure OpenAI Chat Model (Language Model n8n node): Provides the large language model capacity, utilizing an Azure deployment of gpt-4.1 for textual analysis.
Information Extractor (LangChain n8n node): This core AI n8n node feeds the attached text into the Azure AI model with a strict prompt: "Analyze the texts and say if it is an invoice. Just answer 'Yes' or 'No'."
IF: AI Says Yes (IF n8n node): Evaluates the AI's output. If the response contains "Yes," the invoice is deemed verified.
Manual Verification (Gmail n8n node): Activated if the AI fails to classify the document as an invoice. It sends an email requiring a human user to manually review the file and provide necessary approval, demonstrating the resilience of this n8n workflow.
Save PDF Locally (Write Binary File n8n node): The final output n8n node. It saves the verified binary attachment to a local file path, dynamically generating a unique file name using the current timestamp.
Error Handler (Stop and Error n8n node): Stops the n8n workflow execution immediately if the initial Is this PDF? check fails, ensuring clear error reporting.

Related n8n Workflows

Free

Nodes: 9 Nodes
Updated: December 26 2025
View all
Created by

Featured*