AI Agent for Automated Logistics Order Processing via Gmail - n8n Workflow

Automate logistics data entry. This powerful n8n workflow uses a Gmail n8n trigger to capture orders, extracts SKU, quantity, and PO details using an AI Agent (GPT-4o-mini), and logs everything into Google Sheets.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Logistics managers needing to automate inbound order data capture.

  • Operations teams tired of manual data entry from emails into inventory systems.

  • Users looking for advanced examples of how to integrate AI Agents within an n8n workflow.

  • Technical users seeking reliable n8n templates for email parsing.

Overview

Manual processing of inbound logistics orders received via email is slow and error-prone. This specialized n8n workflow solves this by creating a robust, AI-driven pipeline. It starts with the Gmail n8n trigger, identifying relevant purchase order (PO) emails. The core value lies in the AI Agent n8n node, which leverages GPT-4o-mini and a Structured Output Parser to reliably extract complex data—such as multiple SKUs, quantities, PO numbers, and expected delivery dates—from unstructured email bodies.

This extracted data is then restructured and appended automatically to a central Google Sheet. This reliable n8n solution ensures that inventory and logistics teams have immediate, accurate visibility into incoming stock without human intervention. Implementing this n8n template can significantly boost operational efficiency.

How it Works


  1. Email Reception: The process begins with the Email Received n8n trigger, which constantly monitors a specified Gmail account for new messages.

  2. Order Identification: The Is PO? If n8n node filters incoming emails, proceeding only if the subject line contains the phrase "Inbound Order."

  3. Data Extraction (AI Agent): The email subject and body are passed to the AI Agent n8n node. This agent, configured with an explicit system prompt and using the gpt-4o-mini OpenAI Chat Model, is tasked specifically with identifying and extracting the purchaseorder, expecteddelivery_date (normalized to ISO format), and all nested order lines (SKU and quantity). The Structured Output Parser ensures the resulting data is a clean JSON object.

  4. Data Preparation: The Format Purchase Order Lines Code n8n node iterates over the list of extracted order lines. For every single SKU/quantity combination, it creates a separate output item, ensuring that the PO number and delivery date are correctly associated with each line item for Google Sheets insertion.

  5. Storage: Finally, the Store Purchase Order Lines Google Sheets n8n node appends the prepared data as new rows into the designated spreadsheet, completing the n8n workflow automation.

Installation Guide


  1. Import: Copy the provided n8n workflow JSON and import it into your n8n instance.

  2. Gmail Credentials: Set up your Google/Gmail OAuth2 credentials for the Email Received n8n trigger node to allow n8n to monitor your inbox.

  3. OpenAI Credentials: Configure the required API key credentials for the OpenAI Chat Model within the AI Agent setup. This connection is vital for the AI Agent n8n node to function.

  4. Google Sheets Setup: Create a new Google Sheet document with the required columns: PONUMBER, EXPECTEDDELIVERY DATE, SKU_ID, and QUANTITY. Then, update the Store Purchase Order Lines n8n node by selecting your Google Sheet Document ID and the correct Sheet Name (e.g., gid=0).

  5. Activation: Once all credentials and configurations are set, activate the n8n workflow.

Node Details

Email Received (Gmail Trigger n8n node): Serves as the starting point, initiating the n8n workflow upon detecting new emails. Key configuration: Polls for new messages.
Is PO? (If n8n node): A core logic n8n node that filters emails, executing the subsequent AI steps only if the subject contains "Inbound Order."
AI Agent (Langchain Agent n8n node): The brain of this n8n workflow. It takes unstructured text (email content) and uses specialized prompts and tools to generate highly structured JSON output. Key Configuration: Uses gpt-4o-mini model and a detailed system message for logistics data extraction.
Structured Output Parser (Langchain n8n node): Enforces a strict JSON output structure based on a defined schema, maximizing the reliability of the data extracted by the AI Agent n8n node.
Format Purchase Order Lines (Code n8n node): Essential data manipulation n8n node. It transforms the single AI output item (containing an array of lines) into multiple output items, one per order line, preparing the data perfectly for the Google Sheets Append operation.
Store Purchase Order Lines (Google Sheets n8n node): The final action n8n node, appending the structured order line items to the designated spreadsheet columns.

Related n8n Workflows

Free

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

Automation, AI and Analytics for Supply Chain & Business Optimization Helping businesses streamline operations using n8n, AI agents, and data science to enhance efficiency and sustainability. Linkedin: www.linkedin.com/in/samir-saci

Featured*