Predict Shopify stockouts with GPT-4o and email suppliers via Gmail
Needs changesWhat this workflow does
This AI workflow has 10 nodes and runs on a schedule (cron 0 6 * * *). Along the way it connects Shopify, OpenAI Chat Model, Gmail and Google Sheets.
How it runs
Trigger: On a schedule (cron 0 6 * * *).
- Fetch All Products (Shopify): get many (product)
- Fetch Recent Orders (Shopify): get many
- Compute Sales Velocity (Code): runs custom JavaScript code
- Predict Stockout Risk (AI Agent): runs an AI agent, with model: OpenAI — Predict; output parser: Stockout Risk Schema
- Should Reorder? (If): checks a condition and branches into true / false
- Send Reorder Email (Gmail): uses Gmail
- Log to Google Sheets (Google Sheets): append or update
Services it uses
Before you upgrade to n8n 3.0
1 thing in this workflow is removed in n8n 3.0. Fix it before you upgrade:
- AI Agent v1 (old agent modes) in Predict Stockout Risk (v1.8): replace with Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.
Rather not rewrite it? Many of these flows can be rebuilt in Make (free plan).
| Removed in 3.0 | Replace with |
|---|---|
| AI Agent v1 (old agent modes) Predict Stockout Risk (v1.8) | Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent. |
Nodes used (9)
- Schedule Trigger
n8n-nodes-base.scheduleTrigger - Shopify
n8n-nodes-base.shopify - Code
n8n-nodes-base.code - AI Agent
@n8n/n8n-nodes-langchain.agent - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured - If
n8n-nodes-base.if - Gmail
n8n-nodes-base.gmail - Google Sheets
n8n-nodes-base.googleSheets
From the author
🚀 How it works Runs daily at 06:00 UTC, pulls every Shopify product variant's stock level, calculates real sales velocity from the last 7 days of orders, then uses GPT-4o to predict stockout dates and decide whether to reorder — automatically. - 🛍️ Fetches…