Blog · · 4 min read

How to get low-stock alerts and draft supplier orders with n8n and AI

Step-by-step guide to having n8n check your Google Sheets inventory every morning, flag what is running out and draft the supplier order with AI so you only need to review it.

Running out of a product is lost money: the customer who came for it goes to another shop, and the rush order to your supplier costs more. In a small shop, a salon that sells retail products, a bar or a workshop, the inventory usually lives in a spreadsheet nobody looks at until it's too late.

In this guide you'll build an n8n workflow that checks your inventory in Google Sheets every morning, finds the products below their minimum, groups them by supplier and uses AI to write a draft order in Gmail for each one. You just review it and hit send.

What you'll build

A five-step workflow that runs on its own every day:

  1. Daily trigger: a Schedule Trigger node runs at 8:30.
  2. Read the inventory: the Google Sheets node reads your "Inventory" sheet.
  3. Filter and group: a Code node keeps the products below minimum that haven't already been ordered and groups them by supplier.
  4. AI order: a Basic LLM Chain node writes a clear, polite order email for each supplier.
  5. Draft and log: Gmail creates the draft (it doesn't send it) and Google Sheets writes the date in ordered_on.

What you need

  • An n8n instance (cloud or installed free on your computer).
  • Google Sheets and Gmail connected in n8n.
  • An OpenAI (or other AI provider) API key, with a monthly spending limit set in its dashboard.
  • An "Inventory" sheet with these columns: product, sku, stock, minimum, order_qty, supplier, supplier_email and ordered_on (empty).

Step 1: set up the inventory sheet

The key field is minimum: the stock level below which you want to reorder. A simple rule is what you sell during your supplier's delivery time, plus a small buffer. order_qty is what you usually order each time. If you update stock by hand, do it at closing time; if your POS exports to Google Sheets, even better.

Step 2: trigger and read

Add a daily Schedule Trigger at 8:30 (check the workflow time zone in Settings). Connect it to Google Sheets → Get Row(s) pointing at your "Inventory" sheet.

Step 3: filter what's missing and group by supplier

Add a Code node (Run Once for All Items mode) with this code:

const now = new Date();
const cutoff = new Date(now.getTime() - 7 * 86400000); // don't repeat orders within 7 days
const groups = {};
for (const i of $input.all()) {
  const p = i.json;
  const ordered = p.ordered_on ? new Date(p.ordered_on) : null;
  if (Number(p.stock) > Number(p.minimum)) continue;
  if (ordered && ordered > cutoff) continue;
  if (!p.supplier_email) continue;
  const k = p.supplier_email;
  groups[k] = groups[k] || { supplier: p.supplier, email: k, lines: [] };
  groups[k].lines.push(`${p.product} (SKU ${p.sku}): ${p.order_qty} units. Current stock: ${p.stock}`);
}
return Object.values(groups).map(g => ({ json: { ...g, list: g.lines.join('\n') } }));

If nothing is missing, the node returns nothing and the workflow stops without spending on AI. The 7-day rule stops you ordering the same thing twice while the previous order is on its way.

Step 4: write the order with AI

Add a Basic LLM Chain with a small, cheap model (for example, gpt-4o-mini) and this prompt:

You handle purchasing for [BUSINESS NAME]. Write an order email to
{{ $json.supplier }} with these lines, without changing quantities or SKUs:
{{ $json.list }}
- Professional, friendly tone, in English, no more than 6 sentences plus the list.
- Ask them to confirm the order and the delivery date.
- Don't invent prices, discounts or dates.
Return only the email body.

The instruction not to change quantities matters: the AI writes the text, but the numbers always come from your sheet.

Step 5: create the draft and mark as ordered

Connect a Gmail → Create Draft node with the recipient {{ $('Code').item.json.email }}, the subject [BUSINESS NAME] order – {{ $now.format('dd/MM/yyyy') }} and the AI text as the body. Using drafts instead of sending directly lets you check before committing to a supplier; it's the same idea as replying to emails with AI drafts.

Then, for each product ordered, a Google Sheets → Update Row node that matches on sku and writes today's date in ordered_on. When the goods arrive, update stock and clear ordered_on.

If you'd rather not create drafts, swap step 5 for a phone alert from a Telegram bot listing what's running low.

How to test it

  1. In a test row, set stock below minimum and use your own email as supplier_email.
  2. Run the workflow manually and check that the draft appears in Gmail with the right quantities and that ordered_on is filled in.
  3. Run it again: this time no draft should be created.
  4. Raise stock above the minimum in another row and confirm it's skipped.

Cost and good practice

  • Cost: each drafted order costs less than a tenth of a cent in AI API fees. Even with ten suppliers, the monthly cost is negligible.
  • Review your minimums every few months: in peak season (Christmas, summer) they usually need to go up.
  • Get error alerts: set up an error workflow so you know if Gmail or the sheet fails, as explained in error handling in n8n.
  • Combine it with your daily AI report to see yesterday's sales and what needs restocking in a single message.

Start with ready-to-import templates

If you want your customer-service foundation in n8n ready to go, download the free WhatsApp agent or take a look at the full AgentKiosk pack: 8 tested agents in English and Spanish, each with its workflow, prompt and guide, ready to import and combine with these stock alerts.