Skip to content

The moment it happens

Update stock in Supabase and email a reorder for approval

Each stock movement updates your Supabase inventory table, and when an item falls below its reorder level the manager gets an email with Approve and Reject links.

Runs
The moment it happens
Apps
Gmail, Supabase
AI
Not needed
Access
Supabase write; Gmail send

Send this to your assistant

Create a ClickRuntime automation: when a stock movement is posted to this link, update my Supabase inventory table; if stock falls below the reorder level, email the manager with approve and reject links, and record their answer.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

A small warehouse logs stock in and out from a form, and the numbers live in Supabase. Reordering depends on someone spotting a low count and asking the manager, who then has to reply, and the order gets placed days late.

Updating stock the moment it moves and asking for approval by email as soon as an item drops low turns reordering into a one-click decision, with the answer recorded against the request.

What you get out of it

  • Stock figures stay accurate

    Every movement updates the table as it happens, not at the end of the day.

  • Reorders are asked for on time

    The approval email goes out the moment an item crosses its reorder level.

  • One-click decisions

    The manager approves or rejects from the email, on any device, without logging in.

  • A record of every approval

    Each request and its answer is stored in Supabase.

How it works

What happens, step by step

  1. A stock movement is sent to your automation's link from your form or system.

  2. ClickRuntime updates the item's quantity in your Supabase inventory table.

  3. If the new quantity is below the item's reorder level, it creates an approval request and emails the manager Approve and Reject links.

  4. When the manager clicks a link, the request is marked approved or rejected in Supabase.

Before it runs live

  • Connect Google through your own Google app (a one-time, 10-minute setup), so it works with your own Gmail
  • Connect Supabase
  • Paste your automation's link into the other app's webhook settings

What you get

RunsThe moment it happens
Update stock in Supabase and email a reorder for approvaljust nowSucceeded
Email · Reorder approvalReorder Northwind Mug? (8 left) – Order 100 more? Approve: … Reject: …

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Act only on the items that match your own rules, and skip the rest
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other Gmail and Supabase steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
inventory_levels_in_supabase_with_email_approvals.pyexample
import secrets
import base64
from email.message import EmailMessage
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_event, credentials, http

LINK = "https://hooks.clickruntime.com/t/your-trigger-id"
MANAGER = "ops@northwind.com"
SUPABASE = "https://your-project.supabase.co/rest/v1"

def sb(method, path, **kw):
    key = credentials.secret("SUPABASE_KEY")
    r = http.request(method, f"{SUPABASE}/{path}", **kw, headers={"apikey": key, "Authorization": f"Bearer {key}", "Prefer": "return=representation,resolution=merge-duplicates"})
    return r.raise_for_status() or (r.json() if r.content else None)

def send(to, subject, text):
    msg = EmailMessage()
    msg["To"], msg["Subject"] = to, subject
    msg.set_content(text)
    build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).users().messages().send(userId="me", body={"raw": base64.urlsafe_b64encode(msg.as_bytes()).decode()}).execute()

@on_event
def handle(event):
    body = event.json or {}
    if "decision" in body:
        sb("PATCH", f"approvals?id=eq.{body['id']}&token=eq.{body['token']}", json={"status": body["decision"]})
        return {"approval": body["id"], "status": body["decision"]}
    item = sb("GET", f"inventory?sku=eq.{body['sku']}")[0]
    qty = item["quantity"] + int(body["change"])
    sb("PATCH", f"inventory?sku=eq.{body['sku']}", json={"quantity": qty})
    if qty < item["reorder_level"] <= item["quantity"]:
        token = secrets.token_urlsafe(16)
        req = sb("POST", "approvals", json={"sku": body["sku"], "quantity": item["reorder_qty"], "token": token, "status": "pending"})[0]
        links = "\n".join(f"{d.title()}: {LINK}?id={req['id']}&token={token}&decision={d}d" for d in ("approve", "reject"))
        send(MANAGER, f"Reorder {item['name']}? ({qty} left)", f"{item['name']} is down to {qty} (reorder level {item['reorder_level']}).\n"
             f"Order {item['reorder_qty']} more?\n\n{links}")
    return {"sku": body["sku"], "quantity": qty}

FAQ

Common questions

What does the stock movement need to include?
The item's SKU and the change in quantity, positive for stock in and negative for stock out.
How do the Approve and Reject links work?
They point back to your automation's link with the request ID and decision, which updates the request in Supabase.
Can anyone with the email approve?
The links carry a random token for that request, so only someone with the email can use them.
What permissions does it need?
Supabase write; Gmail send. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run for each event the app sends.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Update stock in Supabase and email a reorder for approval” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.