Automated AI Invoice Processing and Inventory Management - n8n Workflow

Streamline procurement and inventory with this powerful n8n workflow. Automatically process email invoices using AI, check Google Sheets stock, and notify Slack or Gmail.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Ideal User Persona

Supply Chain Managers needing faster invoice-to-fulfillment cycles.
E-commerce businesses automating order entry and stock checks.
Operations teams looking for advanced n8n templates for logistics.
Users seeking to implement AI in their n8n workflow to handle unstructured data like invoices.


  • Anyone interested in seeing how complex conditional logic operates within an n8n node chain.

Overview

Handling incoming invoices manually is time-consuming and prone to errors. This specialized n8n workflow solves that problem by providing a fully automated, hands-off solution. The core value of this n8n template lies in its intelligent handling of documents: it uses an advanced n8n node structure with AI to extract complex order details from PDF attachments.

After extraction, the system instantly checks stock levels in Google Sheets. This highly efficient n8n workflow ensures immediate branching: if stock is available, a fulfillment process is initiated and communicated via Slack. If inventory is low, a high-priority purchase requisition is generated, and the procurement team is instantly notified via an automated Gmail message. This intelligent use of the n8n trigger and subsequent logic saves countless hours and prevents stockout situations.

How it Works

The entire process begins with the Gmail Trigger, which acts as the starting n8n trigger, constantly monitoring an inbox for new emails from a specific sender containing attachments.


  1. Extraction: Once triggered, the n8n workflow uses the Extract from File n8n node to pull the text content from the attached invoice PDF.

  2. AI Parsing: An AI Agent (Extract Invoice Record) utilizes the OpenAI Chat Model and a Structured Output Parser n8n node to convert the messy, unstructured text into a clean, schema-compliant JSON object containing SKUs, quantities, and customer data.

  3. Data Recording: The structured data is then written to the designated 'Customer order' sheet using the Sales Order Creation Google Sheets n8n node.

  4. Inventory Check: The Stock & Shortage Check n8n node queries the 'Product inventory' sheet based on the item name.

  5. Conditional Routing: The If Negative n8n node checks if the inventory status returned is 'out of Stock'.

  6. Path A (Out of Stock): If true, the n8n workflow executes the Create Purchase Requisition Google Sheets n8n node and sends a detailed, formatted Send a message notification via Gmail to the procurement team.

  7. Path B (In Stock): If false, the n8n workflow proceeds to the Create Work Order Google Sheets n8n node, documenting the fulfillment task, and then sends an immediate summary notification via the Send Order Summary Slack n8n node.

Installation Guide

To deploy this comprehensive n8n template, follow these steps after importing the provided JSON:


  1. n8n Credentials: Ensure you have OAuth or API key credentials set up for all services: Gmail, Google Sheets, OpenAI, and Slack.

  2. Gmail Trigger Setup: Configure the Gmail Trigger n8n node by adding your Gmail credentials and updating the 'Sender' filter to match the source of your invoices.

  3. OpenAI Integration: Connect your OpenAI API key to the OpenAI Chat Model n8n node. This is crucial for the AI extraction step in this n8n workflow.

  4. Google Sheets Configuration: For all Google Sheets n8n nodes (Sales Order Creation, Stock & Shortage Check, etc.), update the 'Document ID' to point to your specific inventory and order management spreadsheet. The required sheet names are 'Customer order', 'Product invetory', and 'Purchase Requisition'.

  5. Recipient Updates: Update the target email in the Send a message n8n node (for procurement notifications) and select the correct channel ID in the Send Order Summary Slack n8n node. Test the n8n trigger with a sample PDF invoice to validate the logic.

Node Details

This n8n workflow leverages several specialized n8n node types for its high functionality:

Gmail Trigger (n8n trigger):
Function: Starts the n8n workflow upon receiving an email matching the filter criteria. It handles downloading the attached PDF invoice.
Key Configuration: Filters for specific 'Sender' and ensures 'Download Attachments' is enabled.
Extract from File (n8n node):
Function: Performs Optical Character Recognition (OCR) or text extraction on the binary PDF attachment, preparing it for AI processing.
Key Configuration: Operation set to pdf, targeting the attachment0 binary property.
Extract Invoice Record (AI Agent n8n node):
Function: Orchestrates the AI components. It feeds the raw text into the OpenAI Chat Model and uses the Structured Output Parser to enforce the output format (JSON schema for invoice data).
Key Configuration: Input is the extracted text; output is structured JSON with keys like sku, quantity, and orderid.
Google Sheets (n8n node - Sales Order Creation / Requisition / Work Order):
Function: Appends the newly extracted data to relevant sheets for record-keeping and production planning. The n8n template manages three distinct data repositories.
Key Configuration: Uses 'append' operation, mapping JSON output fields to specific spreadsheet columns.
If Negative (Flow Control n8n node):
Function: Determines the subsequent path based on the inventory status returned from the Google Sheets lookup.
Key Configuration: Condition checks if the lookup result Stock is equal to out of Stock.
Gmail (n8n node - Send a message):
Function: Sends a professionally formatted HTML email containing the purchase requisition details when stock is low.
Key Configuration: Uses expression logic for dynamic subject lines and content injection.
Slack (n8n node - Send Order Summary):
Function: Notifies the production team via a designated Slack channel immediately upon creating a new work order.

Related n8n Workflows

Free

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

We are an AI Automation Agency focusing on various AI Automation Services like, workflow automation, shopify automation, chatbot developerment, custom ai agent development and more.

Featured*