{
  "name": "Predict Shopify stockouts with GPT-4o and email suppliers via Gmail",
  "nodes": [
    {
      "id": "5b494ae5-5c7b-4aeb-939c-033fad6d230a",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        19840,
        5152
      ],
      "parameters": {
        "width": 680,
        "height": 356,
        "content": "## Inventory Reorder Prediction\nVersion 1.0.0 — E-Commerce\n\nRuns daily, pulls all Shopify product variants with inventory levels, fetches orders from the last 7 days to compute sales velocity, then us"
      }
    },
    {
      "id": "d4559dd4-0805-41c3-8f7e-14039c1b9191",
      "name": "Prerequisites",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        19856,
        5520
      ],
      "parameters": {
        "width": 420,
        "height": 276,
        "content": "## Prerequisites\n- Shopify store with Admin API access (Custom App)\n- OpenAI API key (GPT-4o)\n- Gmail account for reorder notifications\n- Google Sheets for reorder log\n\nShopify setup: Admin => Apps an"
      }
    },
    {
      "id": "d4dbdfb5-d585-4502-9431-5c16ab689f55",
      "name": "Setup Required",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20544,
        5328
      ],
      "parameters": {
        "width": 420,
        "height": 404,
        "content": "## Setup Required\n1. Fetch Products + Fetch Orders — connect 'Shopify Access Token API' credential\n2. OpenAI sub-node — connect OpenAI credential\n3. Send Reorder Email — connect Gmail OAuth2 credentia"
      }
    },
    {
      "id": "188a9caf-38bf-4c4c-ba2f-af9566181e89",
      "name": "How It Works",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        19840,
        5824
      ],
      "parameters": {
        "width": 420,
        "height": 488,
        "content": "## How It Works\n1. Runs daily at 06:00 UTC via cron schedule\n2. Fetches all Shopify products and their variant inventory levels\n3. Fetches all orders from the past 7 days and sums units sold per varia"
      }
    },
    {
      "id": "c3e2e2b9-77bc-493f-a69d-d26fc789f0d9",
      "name": "Daily Inventory Check",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        20256,
        5936
      ]
    },
    {
      "id": "5aa9c8f2-93f0-4e2e-ab51-7c4765f8e2c6",
      "name": "Fetch Products note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20368,
        5792
      ],
      "parameters": {
        "width": 270,
        "height": 96,
        "content": "Pulls all product variants with current inventory_quantity from Shopify"
      }
    },
    {
      "id": "1f8a64ed-475b-4589-a783-9ce974891dea",
      "name": "Fetch All Products",
      "type": "n8n-nodes-base.shopify",
      "position": [
        20416,
        5936
      ]
    },
    {
      "id": "b795a9d5-1a42-4423-8e22-060b08c40f7c",
      "name": "Fetch Orders note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20656,
        5792
      ],
      "parameters": {
        "width": 260,
        "height": 96,
        "content": "Fetches all orders from the last 7 days to calculate sales velocity"
      }
    },
    {
      "id": "0825665e-ad08-4576-836e-baa074294a2d",
      "name": "Fetch Recent Orders",
      "type": "n8n-nodes-base.shopify",
      "position": [
        20672,
        5920
      ]
    },
    {
      "id": "a805af61-e0d0-42d9-994a-7412ebed5155",
      "name": "Velocity note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20928,
        5792
      ],
      "parameters": {
        "width": 238,
        "height": 96,
        "content": "Joins products + orders, computes velocity (units/day) and days until stockout per variant"
      }
    },
    {
      "id": "44d9823e-3f64-4220-8a3f-fae0f242048c",
      "name": "Compute Sales Velocity",
      "type": "n8n-nodes-base.code",
      "position": [
        20944,
        5904
      ]
    },
    {
      "id": "eabd760d-b5c7-4506-af34-a71c03a0a05d",
      "name": "Predict note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        21184,
        5792
      ],
      "parameters": {
        "width": 302,
        "height": 96,
        "content": "AI Agent assesses stockout risk and recommends reorder quantity with 30-day + 20% safety buffer"
      }
    },
    {
      "id": "8127ab51-ad94-4f26-a48f-12d04ef81f59",
      "name": "Predict Stockout Risk",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        21216,
        5904
      ]
    },
    {
      "id": "9b30b060-c895-458a-942a-2160cb146bd5",
      "name": "OpenAI — Predict",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        21088,
        6144
      ]
    },
    {
      "id": "acbb6299-063c-4fe8-b4d2-89f97ab63235",
      "name": "Stockout Risk Schema",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        21408,
        6128
      ]
    },
    {
      "id": "7781da67-6c37-4b3c-b52b-84213d3e8050",
      "name": "Should Reorder note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        21504,
        5792
      ],
      "parameters": {
        "width": 255,
        "height": 96,
        "content": "Routes to email supplier (true) or skip to log only (false)"
      }
    },
    {
      "id": "c9d3f410-9ba0-49ae-b11a-fc6eec70ff5d",
      "name": "Should Reorder?",
      "type": "n8n-nodes-base.if",
      "position": [
        21536,
        5904
      ]
    },
    {
      "id": "c6e17c0d-0253-44ff-aadf-978ae89a753f",
      "name": "Email note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        21776,
        5744
      ],
      "parameters": {
        "width": 255,
        "height": 60,
        "content": "Sends reorder request to supplier with full variant details"
      }
    },
    {
      "id": "be5298cc-5a62-4e86-8cf8-641fceb8d2c5",
      "name": "Send Reorder Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        21808,
        5840
      ]
    },
    {
      "id": "3c432a16-5374-4310-a221-5724ded8150a",
      "name": "Log note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        22128,
        5776
      ],
      "parameters": {
        "width": 265,
        "height": 144,
        "content": "Logs all reorder decisions (triggered or skipped) to Google Sheets for tracking"
      }
    },
    {
      "id": "eff4aab4-2149-4f6b-860f-1d63706fa714",
      "name": "Log to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        21840,
        6096
      ]
    }
  ],
  "connections": {
    "Should Reorder?": {
      "main": [
        [
          {
            "node": "Send Reorder Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch All Products": {
      "main": [
        [
          {
            "node": "Fetch Recent Orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI — Predict": {
      "ai_languageModel": [
        [
          {
            "node": "Predict Stockout Risk",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Send Reorder Email": {
      "main": [
        [
          {
            "node": "Log to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Recent Orders": {
      "main": [
        [
          {
            "node": "Compute Sales Velocity",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stockout Risk Schema": {
      "ai_outputParser": [
        [
          {
            "node": "Predict Stockout Risk",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Daily Inventory Check": {
      "main": [
        [
          {
            "node": "Fetch All Products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Predict Stockout Risk": {
      "main": [
        [
          {
            "node": "Should Reorder?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compute Sales Velocity": {
      "main": [
        [
          {
            "node": "Predict Stockout Risk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}