Automated Invoice Processing from Microsoft Outlook using AI Document Understanding - n8n Workflow

Use this powerful n8n workflow to automatically monitor Outlook for invoices, classify attachments using Google Gemini AI, extract critical data, and append structured output to Microsoft Excel 365.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Finance and Accounting teams looking to automate Accounts Payable (AP) data entry.
Businesses receiving large volumes of invoices via email.
Automation Specialists seeking advanced examples of using the n8n node ecosystem for document understanding.
Users looking for ready-made n8n templates for Microsoft 365 and AI integration.

Overview

This automation solves the tedious and error-prone process of manually handling incoming supplier invoices via email. By leveraging the power of an n8n workflow combined with advanced AI capabilities from Google Gemini, the solution can intelligently classify incoming emails and attachments. This saves hundreds of hours of manual labor by filtering out non-invoice attachments, performing Optical Character Recognition (OCR) style extraction, and outputting clean, structured data.

This specific n8n template provides a robust, scheduled mechanism that monitors your designated Accounts Receivable Outlook mailbox. It ensures that only validated invoice documents are processed, drastically reducing resource consumption and improving data accuracy before appending the extracted data to a Microsoft Excel spreadsheet for reconciliation.

How it Works

This comprehensive n8n workflow begins execution via a Schedule Trigger, running every hour to check for new messages.


  1. Email Fetch and Classification: The Get Recent Messages n8n node fetches all emails received in the last hour with attachments from a specified Outlook folder. The email body is converted to Markdown, and the Message Classifier (using an AI Language Model n8n node) determines if the email context is related to an 'invoice being issued'.

  2. Message Loop and Download: For each qualifying message, the Download Attachments n8n node retrieves the files. A Code n8n node then splits multiple attachments into individual data items.

  3. Attachment Classification (AI Vision): Each attachment is prepared (converted to base64) and sent to the Invoice Classifier With Gemini 2.0 (via an HTTP Request n8n node). This step uses the AI’s document understanding capability and a structured schema to verify two critical points: Is this document an invoice, and is it issued to our company?

  4. Filtering and Extraction: The Filter Invoices n8n node retains only the documents that meet the AI's positive classification criteria. If an invoice is found, the File-Based OCR with Gemini 2.0 n8n node is called. This advanced step uses Gemini's forced JSON schema response feature to extract granular details like invoice number, total amount, supplier address, and line item services.

  5. Output and Logging: The extracted structured data is combined with the original email metadata in the Parse Output n8n node. Finally, this rich data is appended as a new row to a designated Microsoft Excel 365 spreadsheet. If an attachment was an invoice but failed extraction, the flow logs an empty record to maintain the email reference.

Installation Guide

To deploy this powerful 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 section (New -> Import from JSON).

  2. Credential Setup: This n8n template requires three main credentials:

Microsoft Outlook OAuth2 API: Used for fetching and downloading emails/attachments. Ensure this credential has access to the target mailbox/folder.
Google Gemini (PaLM) API: Required for both the AI classification and the advanced OCR/extraction HTTP requests. This API key powers the core document understanding logic.
* Microsoft Excel OAuth2 API: Needed to connect to and write data to your Excel Workbook.

  1. Outlook Configuration: In the Get Recent Messages n8n node, ensure the filtersUI configuration points to the correct foldersToInclude (your Accounts Payable mailbox ID).

  2. Excel Configuration: In the Microsoft Excel 365 n8n node, select your target Workbook ID and Worksheet ID where the extracted invoice data should be logged.

  3. Activation: Save the n8n workflow and toggle the workflow to 'Active'. The n8n trigger will now execute hourly.

Node Details

Schedule Trigger (n8n trigger): The entry point, set to run every hour to check for new invoices.
Microsoft Outlook (Get Recent Messages, Download Attachments): This n8n node connects to Microsoft 365 to retrieve emails filtered by received time and the presence of attachments. It also handles the secure download of the binary file data for processing.
Code (Split Attachments): A custom scripting n8n node essential for iterating over multiple binary files attached to a single email, ensuring each file is processed individually.
Langchain Text Classifier (Message Classifier): Uses an AI language model (Gemini) to determine the intent of the email based on text analysis, allowing the n8n workflow to filter out irrelevant messages early.
HTTP Request (Invoice Classifier With Gemini 2.0 & File-Based OCR with Gemini 2.0): These are critical n8n nodes that interact directly with the Gemini API for document vision tasks. They are configured using specific JSON schemas (response_schema) to force structured output, enabling highly accurate extraction of invoice details (dates, amounts, services).
Filter (Filter Invoices): A core logic n8n node that uses the boolean output from the AI classification step to ensure only positively identified invoices continue through the data extraction flow.
Set (Parse Output, Empty Response): Used to map the final extracted data into a clean JSON structure, ensuring the output is standardized before being sent to the spreadsheet.
Microsoft Excel 365: The final sink n8n node, configured to append the structured invoice information to a specified Excel Workbook, ready for review.

Related n8n Workflows

Free

Nodes: 16 Nodes
Updated: December 26 2025
View all
Created by
Jimleuk
Jimleuk

Freelance consultant based in the UK specialising in AI-powered automations. I work with select clients tackling their most challenging projects. For business enquiries, send me an email at [email protected] LinkedIn: https://www.linkedin.com/in/jimleuk/ X/Twitter: https://x.com/jimle_uk

Featured*