Automated Predictive Inventory Reordering for E-commerce - n8n Workflow

Deploy this advanced n8n workflow to automate Shopify inventory management. Calculates dynamic reorder points, sends purchase orders via Gmail/API, and logs all data to Google Sheets. Find more powerful n8n templates here.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

E-commerce Managers and Operations Directors seeking to minimize stockouts and reduce carrying costs.
Supply Chain Specialists who need a customizable, data-driven automated reordering system.
n8n power users looking for complex n8n templates integrating multiple platforms (Shopify, Sheets, Slack, Gmail).
Businesses relying on Shopify for sales and Google Sheets for master inventory configuration.

Overview

Reactive inventory management leads to missed sales opportunities and costly emergency shipments. This sophisticated n8n workflow transforms your supply chain operations by implementing predictive analytics directly into your fulfillment process. Running on a schedule set by the n8n trigger, this solution dynamically calculates sales velocity and uses that data to determine optimal reorder points and safety stock levels for every SKU. This specific n8n workflow template seamlessly integrates Shopify data (inventory, orders) with critical business parameters stored in Google Sheets (supplier lead times, costs, MOQs).

The automation automatically checks critical business rules—such as budget limits and minimum order quantities (MOQ)—before generating and sending automated Purchase Orders (POs) via Gmail or supplier API endpoints. It also offers invaluable insights by detecting slow-moving stock and alerting the team via Slack to critical stockout risks, ensuring you maintain optimal inventory health with minimal manual intervention. This complex n8n node configuration ensures reliability and adherence to your financial constraints.

How it Works

The entire process is initiated by the Hourly Trigger, a core n8n trigger. The flow executes in the following major phases:


  1. Initialization and Data Collection: The initial n8n node (Workflow Configuration) sets global variables (e.g., safety stock days, budget limits). It simultaneously fetches live data from Shopify (inventory levels, product details, last 30 days of orders) and essential business context from Google Sheets (Inventory Master, Suppliers, PO Log).

  2. Analysis and Calculation: The Merge All Data Sources n8n node consolidates the inputs. A custom Code n8n node (Calculate Sales Velocity) calculates SKU velocity (7-day and 30-day averages). Following this, Calculate Dynamic Reorder Point computes the required order quantity and Calculate Stockout Risk assesses immediate urgency.

  3. Conditional Routing & Risk Mitigation: The workflow checks if the Reorder Point is reached. If critical stockout risk is detected, it immediately sends an alert via Slack and attempts mitigation by checking the Multi-Warehouse Distribution Logic n8n node for possible internal transfers.

  4. Order Generation Gates: If reorder is required, the flow passes through multiple conditional n8n nodes: checking supplier availability, ensuring it's a Business Day, verifying the MOQ Met, and adhering to the Budget Limit and Large Order Approval Needed thresholds.

  5. Prioritization and Formatting: The Optimize Profit Priority Code n8n node ranks required PO line items based on profitability (margin vs. velocity vs. carrying cost).

  6. PO Communication and Logging: The workflow structures the PO items, groups them by supplier (Prepare PO Email Context), and sends the official PO using the Gmail n8n node or the HTTP Request n8n node (Supplier API). It then logs the PO status to the Google Sheets PO Log and posts an alert to Slack.

  7. Monitoring and Insights: Separately, the process detects slow-moving items (Detect Slow-Movers), sends proactive suggestions to Slack, and writes key performance metrics to Google Sheets dashboards and an external accounting system, providing a complete feedback loop.

Installation Guide

To deploy this powerful n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON and import it into your self-hosted or cloud n8n instance.

  2. Credentials Setup: You must establish connections for the following services:

Shopify: Create a Shopify credential (Access Token authentication) for the Shopify n8n node.
Google Sheets: Create a Service Account credential for Google Sheets. Ensure the service account has read/write access to your Inventory Master, Suppliers, PO Log, and Metrics spreadsheets. Fill in the specific Sheet IDs as environment variables or directly in the documentId fields (e.g., <PLACEHOLDERVALUEInventory Master Google Sheet ID_>).
Gmail: Set up an OAuth2 or Service Account credential for the Gmail n8n node to send purchase orders.
Slack: Configure a Slack credential and replace the placeholder channel IDs in the Slack n8n node parameters with the IDs of your desired alert and summary channels.

  1. Configuration: Edit the Workflow Configuration Set n8n node to define your specific store URL, safety stock, budget limits, and thresholds.

  2. Activation: Once all credentials and placeholder values are set, activate the n8n workflow.

Node Details

Hourly Trigger (n8n trigger): The starting n8n node, set to run every hour, ensuring continuous, near real-time inventory monitoring and calculation.
Shopify Node (Get Inventory Levels, Get Product Details, Get Last 30 Days Orders): These n8n nodes pull all required transactional and static data from Shopify for analysis.
Google Sheets Node (Read Inventory Master, Read Suppliers, Read PO Log): Critical n8n nodes that fetch configurable business parameters (lead times, MOQs, current PO history) not stored in Shopify.
Calculate Sales Velocity (Code n8n node): A custom Code n8n node that aggregates 30-day order history to calculate average daily sales, crucial for predictive modeling.
Calculate Dynamic Reorder Point (Code n8n node): Computes the optimal restocking threshold using the formula: (Avg Daily Sales Lead Time) + Safety Stock.
Check Reorder Point Reached (If n8n node): The primary decision gate, routing items that fall below the dynamic reorder point into the ordering sub-workflow.
Prepare PO Email Context (Code n8n node): Groups the line items by supplier, assigns a unique PO number, and formats the data into the HTML structure required by the Gmail n8n node.
Gmail Node (Send PO Email): This n8n node sends the final, formatted purchase order directly to the supplier's email address.
Slack Node (Alert Critical Stock Risk, Alert Slow-Mover Suggestions, Send Daily Summary): Multiple Slack n8n nodes provide real-time visibility into inventory risks and strategic recommendations.


  • Update Purchase Order Log (Google Sheets n8n node): Writes the status and details of the newly created PO back to your centralized PO Log sheet, maintaining data integrity.

Related n8n Workflows

Free

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

Automation | AI workflows, lead generation & data operations

Featured*