Automate inventory management using this advanced n8n workflow. It combines real-time stock data, sales velocity, and OpenAI forecasting to automatically create and dispatch purchase orders.
Download this n8n workflow template and start using it instantly.
Supply Chain Managers looking to transition from reactive to proactive, AI-driven inventory control.
E-commerce or Retail businesses struggling with stockouts or overstocking issues.
Developers needing robust n8n templates for integrating multiple ERP, warehouse, and AI services.
Technical teams who require a complex, scheduled n8n workflow that performs data merging, advanced logic, and external API communication.
Inventory management is typically a reactive process, often leading to either expensive stockouts or wasteful overstocking. This sophisticated n8n workflow solves this by introducing predictive intelligence powered by OpenAI.
The automation runs on a set schedule, autonomously gathering data from your warehouse and sales systems. It utilizes a custom n8n node combination, including the powerful OpenAI integration, to generate precise demand forecasts and recommend reorder quantities. If a product crosses the AI-defined reorder threshold, the n8n workflow automatically creates a detailed purchase order (PO), sends it to the relevant supplier via API, logs the transaction in your ERP system, and saves the detailed record (including AI confidence levels) to a database.
This complete solution demonstrates how to use the n8n platform to build critical, scalable business operations, providing a highly efficient alternative to manual procurement processes. It is a perfect example of an AI-automation workflow that drives tangible business value.
This n8n workflow operates in five distinct phases, triggered by an hourly schedule:
Schedule Trigger n8n trigger every six hours. This immediately triggers parallel HTTP requests using the n8n node architecture to fetch current stock levels and recent sales velocity data (30-day velocity).Code n8n node efficiently merges the inventory data and sales data based on the shared productid. This creates a comprehensive dataset ready for analysis.AI Demand Forecasting n8n node (leveraging OpenAI). The AI analyzes stock levels, sales trends, lead times, and reorder points to determine if replenishment is necessary, providing a concrete recommendation (shouldreorder: true/false) and a recommended_quantity.Filter n8n node checks the AI's recommendation. Only items marked for reorder proceed. A subsequent Code n8n node generates a complete, structured Purchase Order document, calculating costs, setting expected delivery dates, and embedding the AIโs reasoning as notes.HTTP Request n8n node.HTTP Request.Send Notification Email about the automatic PO creation.To implement this n8n workflow template, follow these steps:
Send Notification Email n8n node.HTTP Request n8n nodes:https://your-warehouse-api.com/...) with your actual API endpoints.Authorization header bearer tokens/API keys in the parameters of each request.Send PO to Supplier and Log to ERP System nodes to match your respective API requirements.Schedule Trigger n8n trigger will start the inventory check automatically every six hours.This advanced n8n workflow utilizes several key nodes to achieve end-to-end automation:
Schedule Trigger (n8n trigger):
Function: Starts the entire process at predefined intervals.
Key Configuration: Set to run every 6 hours (hoursInterval: 6).
Fetch Current Inventory & Fetch Sales Velocity (HTTP Request n8n node):
Function: Retrieves necessary real-time data from external APIs (Warehouse and Sales/CRM).
Key Configuration: Requires replacement of placeholder URLs and updating Authorization Bearer Tokens in headers. Fetch Sales Velocity uses a query parameter for days: 30.
Merge Inventory & Sales Data (Code n8n node):
Function: Takes two parallel input streams and combines inventory and sales metrics based on productid for AI consumption.
Key Configuration: Contains custom JavaScript logic specifically tailored for this merging operation.
AI Demand Forecasting (OpenAI n8n node):
Function: Uses large language models (GPT-4 recommended) to analyze combined data, forecast future demand, and decide if a reorder is necessary.
Key Configuration: Uses a custom API call to send structured data to the model. Requires valid OpenAI credentials.
Parse AI Response (Code n8n node):
Function: Safely parses the JSON output generated by the AI model, ensuring data integrity and preparing key fields (like shouldreorder) for downstream filtering.
Filter: Reorder Needed (Filter n8n node):
Function: Implements core logic flow control by only allowing items where shouldreorder is explicitly true to proceed to the purchase stage.
Create Purchase Order (Code n8n node):
Function: Dynamically constructs the final Purchase Order object, generating a unique PO number, calculating totalcost, and determining the expected_delivery based on the product's lead time.
Send PO to Supplier & Log to ERP System (HTTP Request n8n node):
Function: Handles external API communication to finalize the transaction. One sends the PO to the vendor, the other logs it in the company ERP system.
Key Configuration: Requires customization of body parameters to match specific external vendor/ERP schemas.
Save to Database (Postgres n8n node):
Function: Provides persistent logging of the entire PO and forecast data into a PostgreSQL database via an executeQuery operation.
Send Notification Email (Email Send n8n node):
* Function: Alerts the necessary team members (e.g., procurement) that an automatic PO has been generated by the n8n workflow.
Use this robust n8n workflow to automate Instagram Reels creation, combining OpenAI GPT content generation, Creatomate video rendering, and Slack approval. A powerful n8n template for social media automation.

Automate competitor monitoring using this n8n workflow. Scrape web data, combine with RSS feeds, and use OpenAI GPT-4 to generate actionable market intelligence reports and sales talking points.

Automate company research for sales using an advanced n8n workflow. Enrich Google Sheets data with pricing, market type, and integrations via AI Agents and web scraping tools. Find more n8n templates here.

Use this advanced n8n workflow to automatically fetch HighLevel opportunities, classify lead intent using Azure OpenAI GPT-4o-mini, and route leads instantly to the appropriate sales or support team via email. Perfect for high-volume CRM automation.

Use this n8n workflow to instantly process new leads generated in ERPNext. An AI agent classifies inquiries, routes notifications to the correct internal contacts via Microsoft Outlook.

The AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.







































