Skip to main content
Running out of stock means lost sales and disappointed customers. Over-ordering means cash tied up in shelves. A simple alert workflow keeps you on the right side of both.
Before you start: you’ll need a products or inventory table with a stock quantity column, plus a notification channel like Slack, email, or SMS. See Connect Slack or Send Emails.

The Flow at a Glance

Check

Scan inventory for items below threshold

Alert

Notify the purchasing team once per item

Reset

Clear alert when stock is replenished

Step 1: Create the Workflow

1

Open Workflows

In your project, go to Workflows > New Workflow. Name it Low-Stock Alerts.
2

Add a Schedule trigger

Click Add Trigger > Schedule. Set to every hour.
If you also want instant alerts the moment a sale pushes stock below threshold, add a second trigger on your orders table (fires after each purchase). The two triggers complement each other.

Step 2: Query for Low-Stock Items

Add a Database Query action:
SELECT id, name, sku, stock_quantity, reorder_threshold
FROM products
WHERE stock_quantity <= reorder_threshold
  AND stock_quantity > 0
  AND low_stock_alerted_at IS NULL
The low_stock_alerted_at IS NULL check prevents spam — once you’ve alerted on an item, you don’t re-alert until stock is replenished and cleared.
Make sure every product row has a reorder_threshold value set. Rows with NULL thresholds silently fail the comparison and never trigger alerts.

Step 3: Send Slack Notifications

For each low-stock product, add a Send Slack Message action:
:warning: Low stock alert — {{row.name}} ({{row.sku}})

Current: {{row.stock_quantity}}
Threshold: {{row.reorder_threshold}}

<@U123456> — time to reorder
<https://app.hiveku.com/inventory/{{row.id}}|Update inventory>
Tag the person responsible for purchasing with <@USER_ID>. Link back to your inventory admin so they can mark a reorder in progress.

Step 4: Mark as Alerted

After the Slack message sends, update the database:
UPDATE products
SET low_stock_alerted_at = now()
WHERE id = {{row.id}}
This is what prevents duplicate alerts. Without it, every hourly tick would re-alert the same low-stock items.

Step 5: Handle Out-of-Stock Separately

Items that hit zero need different treatment — they’re no longer “low,” they’re gone. Add a second query:
SELECT id, name, sku
FROM products
WHERE stock_quantity = 0
  AND out_of_stock_alerted_at IS NULL
Send a more urgent message — maybe via SMS using Twilio — and flag the product as out-of-stock in your UI automatically.

Step 6: Reset When Restocked

Create a small workflow (or a database trigger) that fires when stock is replenished:
1

Trigger on inventory update

Database trigger on products UPDATE when stock_quantity goes up.
2

Check if now above threshold

IF NEW.stock_quantity > NEW.reorder_threshold THEN
  NEW.low_stock_alerted_at := NULL;
  NEW.out_of_stock_alerted_at := NULL;
END IF;
Now when stock drops again, the alert fires fresh.

Advanced: Velocity-Based Alerts

Fixed thresholds are blunt. A better approach: alert based on days of inventory remaining, using recent sales velocity.
1

Calculate velocity

SELECT product_id, COUNT(*) / 30.0 as daily_velocity
FROM order_items
WHERE created_at >= now() - interval '30 days'
GROUP BY product_id
2

Compute days remaining

days_remaining = stock_quantity / daily_velocity
3

Alert at 14 days, 7 days, 0 days

Lead time-aware reorders — the team gets warned before the situation is critical.

Connecting to E-Commerce Platforms

If you’re using Shopify, WooCommerce, or BigCommerce for storefront, pull inventory via their webhooks rather than maintaining a separate table:
  • Shopify: subscribe to inventory_levels/update
  • WooCommerce: Stock change webhook
  • BigCommerce: store/product/inventory/updated
Mirror the inventory into your Hiveku DB so the alert workflow has a consistent source of truth.

Multi-Channel Alerts

Different urgency, different channel:
  • Non-urgent low stock: Slack message to #ops
  • Out of stock: Slack + email to purchasing manager
  • Bestseller out of stock: SMS to manager (see Connect Twilio)

Out-of-Stock Page Handling

When a product hits zero, your product page should respond:
  • Hide or gray-out the “Add to Cart” button
  • Show an “Out of stock” badge
  • Offer a “Notify me when available” signup form
  • When stock returns, auto-email the waitlist
The back-in-stock waitlist is one of the highest-converting email lists you’ll ever build. Users explicitly asked to know. Send them the moment you have inventory.

Verify It Worked

1

Manually lower a product's stock

Pick a test product, set stock_quantity to 1 below its reorder_threshold.
2

Trigger the workflow

Either wait for the hourly run, or hit Run Now from the workflow page.
3

Check Slack

You should see the alert message in the configured channel.
4

Test the reset

Update stock back above threshold. The low_stock_alerted_at should clear automatically. Lower it again — alert should re-fire.

Troubleshooting

Raise your reorder_threshold values, or switch to a daily digest format — one message listing all low-stock items rather than one per product. Batch the query results into a single Slack message.
Most common cause: product rows have NULL reorder_threshold. Run SELECT COUNT(*) FROM products WHERE reorder_threshold IS NULL and backfill. Second most common: the workflow is disabled — check the toggle in the top right.
The low_stock_alerted_at flag isn’t being cleared on restock. Add the reset logic described in Step 6, or manually clear stale flags: UPDATE products SET low_stock_alerted_at = NULL WHERE stock_quantity > reorder_threshold.
Slack user IDs differ from usernames. Open the user’s Slack profile, click the ”…” menu, copy the member ID (starts with U). Use that in the mention: <@U123456>.
Your product page fetches stock at render time but caches. Either disable caching on product pages, or add a stock check at the API layer that runs fresh on every page load.

What’s Next?

Build Product Pages

Set up the storefront side of your e-commerce

Send SMS with Twilio

Wire up SMS for urgent alerts