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.
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
A stock movement is sent to your automation's link from your form or system.
ClickRuntime updates the item's quantity in your Supabase inventory table.
If the new quantity is below the item's reorder level, it creates an approval request and emails the manager Approve and Reject links.
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
Build your own
Need it to work differently?
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
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?
How do the Approve and Reject links work?
Can anyone with the email approve?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Save form leads to Supabase and reply to them by email
Each new lead from your form is checked, scored and saved to Supabase, gets a reply from your Gmail, and you hear about the high-value ones.
See how it worksFind Reddit posts from likely customers and email the best ones
Every hour, Reddit posts about the problem your product solves are scored, saved in Supabase, and the promising ones are emailed to you.
See how it worksDraft support replies in Gmail from your Supabase knowledge base
New support emails get a draft reply in Gmail based on answers stored in your Supabase knowledge table, and replies you send are saved back as new knowledge.
See how it worksKeep exploring
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.