See llms.txt for all machine-readable content.

Back to Templates

Propose and approve inventory reorders with Google Sheets, Gmail and Gemini 4

Inventory forecasting and purchase order automation for small retailers using Google Sheets: this workflow reads stock and sales, proposes supplier orders and asks you to approve each one by email. It handles empty sheets, invalid rows, repeat weekly runs and broken AI notes. Uncertain sends stay on hold instead of becoming another order.

Last updated: November 2026.

Quick Overview

This inventory forecasting and purchase order automation kit uses completed sales weeks to calculate average weekly demand and its standard deviation. The reorder point is lead-time demand plus safety stock, calculated as safetyFactor times weekly standard deviation times the square root of lead-time weeks. Stock on hand and quantities in open POs count toward inventory position. When that position reaches the reorder point, the suggestion covers lead time plus the review period, rounded up to MOQ and pack size. Gemini 4 explains the figures but never calculates quantities. Google Sheets holds the order history; Gmail handles approval, supplier delivery and daily checks.

How it works

  1. Daily Check or Manual Run starts Config, Read Products, Read Sales and Read Orders. Empty reads still produce an item.
  2. Summarize Daily Checks and Email Daily Check report zero stock, overdue sent orders and pending or uncertain orders. Reorder Day? lets the proposal lane run on the configured weekday.
  3. Forecast Reorders validates products, sales and open PO lines. Input Valid? sends bad batches to Log Invalid Input and Alert Run Failure. Zero history produces no automatic order. Sparse activity and a latest-week spike appear as review flags.
  4. Orders Needed? sends a no-reorder email when nothing new qualifies. Review Orders handles one supplier at a time. Reserve Pending PO records its week-and-supplier key before any approval request.
  5. Explain Proposed PO uses Gemini 4 Model. Prepare Approval checks the JSON, repairs literal newlines inside strings and falls back to a fixed note when the model fails.
  6. Request PO Approval waits for an explicit approval. Approved? allows Email Supplier PO to send only on a true approval result. Mark PO Sent records the Gmail message ID. Mark PO Rejected records rejection or timeout without sending to the supplier.
  7. Hold Uncertain Send and Hold Approval Failure preserve reservations for inspection. External calls retry three times; errors reach Alert Run Failure. Email Run Complete closes the queue.

Setup

  1. Import the JSON into n8n 2.x. Set the workflow timezone and Daily Check time. Serialize production executions with concurrency one and do not overlap manual runs: Sheets does not provide an atomic reservation lock.
  2. Attach Google Sheets OAuth2 to every sheet node. Create products with sku, name, supplier, supplier_email, on_hand, lead_time_days, pack_size, moq and unit_cost. Use one email per supplier.
  3. Create sales with date, sku and qty. Dates must be ISO yyyy-MM-dd text, quantities nonnegative numbers and SKUs present in products. Missing weeks count as zero sales.
  4. Create purchase_orders with po_id, run_key, supplier, supplier_email, lines_json, status, expected_date, total, note, created_at, max_lead_days and gmail_message_id. One row represents a supplier PO. Mark received only after adding received quantities to on_hand. Partial receipts need manual reconciliation.
  5. Attach Gmail OAuth2 to every mail node and OpenRouter to Gemini 4 Model. Any OpenRouter model can be swapped in. Approval links are bearer links, not authenticated purchasing permissions; keep reviewer email access restricted.
  6. In Config change spreadsheetId, productsTab, salesTab, ordersTab, companyName, currency and reviewerEmail. Review lookbackWeeks, safetyFactor, reviewDays, minActiveWeeks, spikeFactor, reorderWeekday, approvalHours and maxNoteChars. Keep asOfDate linked to the current date. Customize weeklySubject, dailySubject, emptyMessage and failureMessage. Use forceReorder only for a controlled test, then disable it.

Quick Answers

Does inventory forecasting and purchase order automation predict accuracy?
No. It applies the documented formula to your sales history, not a measured accuracy guarantee.

Can a repeat run send another PO?
Existing weekly supplier keys suppress fresh proposals. Concurrent runs or ambiguous Gmail retries still require reconciliation; delivery is not exactly once.

What if Gemini 4 returns invalid JSON?
Prepare Approval uses the fixed formula-based note and continues to human approval.

Does it receive goods or pay suppliers?
No. Update stock and received statuses yourself. Totals exclude tax, shipping and currency conversion.

Additional info

Built with n8n. Need an assessment on your business? Feel free to reach out at https://khmuhtadin.com/consultation/