Why Inventory Alerts Are Critical for E-commerce
Stockouts are one of the biggest revenue killers in e-commerce. When a popular product goes out of stock, you do not just lose that sale -- you lose the customer's trust and potentially their future business. According to a Harvard Business Review study, 21-43% of customers will go to a competitor if an item is out of stock. On the flip side, customers who are notified when an item they want is back in stock convert at 2-3 times the normal rate.
An effective inventory alert system works on two levels: internal alerts that warn your team when stock levels drop below a threshold so they can reorder before running out, and customer alerts that notify waitlisted customers when products are restocked so they can purchase immediately. One-Ping makes it easy to set up both with multi-channel delivery.
Two alert types, one API: This guide covers both internal low-stock alerts (Slack + Telegram to your team) and external back-in-stock alerts (Email + WhatsApp to your customers). One-Ping handles both with the same simple API.
Step-by-Step Setup
Define Your Stock Thresholds
The first step is defining when alerts should fire. A common approach uses two thresholds: Low stock (e.g., below 10 units) triggers a warning so you can start the reorder process, and Critical stock (e.g., below 3 units) triggers an urgent alert because you are about to run out. Different products may need different thresholds. Fast-moving products need higher thresholds to account for longer reorder lead times. Slow-moving products can have lower thresholds. Store these thresholds alongside your product data in your database or inventory system.
Set Up Team Alert Channels
Log in to your One-Ping dashboard and configure channels for your inventory team. The recommended setup is: Slack for a dedicated #inventory channel where your entire procurement team can see stock alerts, and Telegram for the inventory manager's phone so they can act on critical alerts immediately, even outside business hours. For low-stock warnings, Slack alone may be sufficient. For critical alerts, use both channels.
Build the Stock Monitoring Script
Create a script that queries your inventory database, checks each product's stock level against its threshold, and sends an alert if the threshold is crossed. The script should track which alerts have been sent to avoid sending the same low-stock alert repeatedly. Only send a new alert when the stock level crosses a threshold boundary (goes from above 10 to below 10). See the code examples below for implementations.
Set Up Back-in-Stock Customer Notifications
When a product is out of stock, offer customers the option to be notified when it returns. Collect their email address or phone number and store it in a waitlist table in your database. When inventory is restocked (either through your script detecting a stock increase or via a webhook from your inventory system), query the waitlist and send notifications through One-Ping to email and optionally WhatsApp. Include a direct link to the product page so they can purchase immediately.
Automate with Scheduled Checks
Set up your stock monitoring script to run automatically. For most stores, checking every 30 minutes is sufficient for low-stock alerts. If you process high order volumes, consider running every 5-10 minutes. Use cron for server-based scripts or an n8n scheduled trigger for a no-code approach. Also set up a hook in your order processing flow to check stock levels immediately after each sale for faster detection.
Code Examples
Node.js: Low-Stock Alert Script
const { Pool } = require('pg'); const pool = new Pool(); async function checkStockLevels() { // Find products below their low-stock threshold const result = await pool.query(` SELECT p.id, p.name, p.sku, p.stock_quantity, p.low_stock_threshold, p.critical_stock_threshold FROM products p WHERE p.stock_quantity <= p.low_stock_threshold AND p.last_stock_alert_at IS NULL OR p.last_stock_alert_at < NOW() - INTERVAL '24 hours' ORDER BY p.stock_quantity ASC `); if (result.rows.length === 0) return; // Separate critical from low-stock const critical = result.rows.filter(p => p.stock_quantity <= p.critical_stock_threshold); const low = result.rows.filter(p => p.stock_quantity > p.critical_stock_threshold); // Critical alert: Slack + Telegram if (critical.length > 0) { const items = critical.map(p => `${p.name} (SKU: ${p.sku}): ${p.stock_quantity} left` ).join('\n'); await fetch('https://api.one-ping.com/send', { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.ONEPING_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ message: `CRITICAL STOCK ALERT\n${critical.length} product(s) nearly out of stock:\n${items}`, channels: ['slack', 'telegram'], metadata: { slack: { attachments: [{ color: '#ff0000', title: `${critical.length} Products Nearly Out of Stock`, text: items, footer: 'Inventory Alert | Reorder immediately' }] } } }) }); } // Low stock alert: Slack only if (low.length > 0) { const items = low.map(p => `${p.name} (SKU: ${p.sku}): ${p.stock_quantity} left` ).join('\n'); await fetch('https://api.one-ping.com/send', { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.ONEPING_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ message: `Low Stock Warning: ${low.length} product(s) running low:\n${items}`, channels: ['slack'], metadata: { slack: { attachments: [{ color: '#ffcc00', title: `${low.length} Products Running Low`, text: items, footer: 'Inventory Alert | Consider reordering' }] } } }) }); } // Mark alerts as sent const ids = result.rows.map(p => p.id); await pool.query( 'UPDATE products SET last_stock_alert_at = NOW() WHERE id = ANY($1)', [ids] ); } checkStockLevels().catch(console.error);
Back-in-Stock Customer Notification
async function notifyWaitlistCustomers(productId) { // Get product details const product = await pool.query( 'SELECT * FROM products WHERE id = $1', [productId] ); // Get waitlisted customers const waitlist = await pool.query( 'SELECT * FROM stock_waitlist WHERE product_id = $1 AND notified = false', [productId] ); if (waitlist.rows.length === 0) return; // Notify each customer for (const customer of waitlist.rows) { await fetch('https://api.one-ping.com/send', { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.ONEPING_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ message: `Great news! ${product.rows[0].name} is back in stock.`, channels: ['email', 'whatsapp'], recipient: customer.phone, metadata: { email: { to: customer.email, subject: `${product.rows[0].name} is Back in Stock!`, html: `<h2>Good news!</h2> <p>${product.rows[0].name} is back in stock.</p> <p>Grab yours before it sells out again:</p> <a href="https://yourstore.com/products/${product.rows[0].slug}"> Buy Now - $${product.rows[0].price} </a>` } } }) }); // Mark as notified await pool.query( 'UPDATE stock_waitlist SET notified = true WHERE id = $1', [customer.id] ); } }
Stock Alert Strategies by Severity
Low Stock Warning
Stock below threshold but not critical. Send to Slack #inventory channel. Include product name, current quantity, and reorder suggestion. Check twice daily.
Critical Stock Alert
Only a few units left. Send to Slack + Telegram immediately. Include urgency indicator and direct link to supplier reorder page. This needs same-day action.
Out of Stock
Zero units remaining. Alert team on all channels. Automatically add "Out of Stock" badge on product page. Activate waitlist signup for customers.
Back in Stock
Product restocked. Notify waitlisted customers via Email and WhatsApp with a direct purchase link. Alert team on Slack that stock has been replenished.
E-commerce Platform Integration
Most e-commerce platforms provide inventory-related webhooks that you can use to trigger stock alerts without polling your database:
- Shopify: Use the
inventory_levels/updatewebhook to trigger checks whenever stock changes. Also useproducts/updateto detect manual inventory adjustments. - WooCommerce: Use the
product.updatedwebhook and check thestock_quantityfield. WooCommerce also has built-in low-stock settings you can hook into. - Custom stores: Add a stock check to your order processing flow. After each sale, check if the product's remaining stock crosses a threshold.
n8n integration: Build a visual n8n workflow that monitors your inventory database on a schedule, checks thresholds, and calls One-Ping for alerts. Our template includes logic for both low-stock team alerts and back-in-stock customer notifications.
Best Practices
- Set per-product thresholds: A product that sells 100 units per day needs a much higher low-stock threshold than one that sells 2 per week. Base thresholds on sales velocity and supplier lead time.
- Avoid alert fatigue: Only send one low-stock alert per product per 24-hour period. Include a count of all low-stock products in a single message rather than separate alerts for each.
- Track alert-to-action time: Measure how quickly your team reorders after receiving an alert. If it consistently takes too long, raise your thresholds to give more lead time.
- Combine with daily digests: In addition to real-time critical alerts, send a daily inventory summary showing all product stock levels, trending items, and projected stockout dates.
- Back-in-stock urgency: Create urgency in customer notifications by mentioning limited quantities. "Back in stock - only 15 units available" converts better than a generic notification.