E-commerce Order Notifications
Route order alerts, refunds, and inventory warnings to the right teams.
E-commerce notifications have different audiences — operations needs to know about new orders, finance cares about refunds, and warehouse cares about inventory. Alphorn routes each event to the right channel.
New order notification
async function onNewOrder(order) {
await fetch("https://app.alphorn.dev/api/webhooks/wh_abc123", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
title: `New order #${order.id}`,
message: `${order.customerName} — ${order.items.length} items — ${order.currency} ${order.total.toFixed(2)}`,
priority: order.total > 500 ? 4 : 2,
tags: ["order", "new", order.total > 500 ? "high-value" : "standard"],
}),
});
}Refund requests
async function onRefundRequested(order, reason) {
await fetch("https://app.alphorn.dev/api/webhooks/wh_abc123", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
title: `Refund requested: Order #${order.id}`,
message: `Amount: ${order.currency} ${order.total.toFixed(2)}\nReason: ${reason}\nCustomer: ${order.customerEmail}`,
priority: 3,
tags: ["order", "refund"],
}),
});
}Low inventory alerts
def check_inventory(products, threshold=5):
for product in products:
if product.stock <= threshold:
requests.post(
"https://app.alphorn.dev/api/webhooks/wh_abc123",
json={
"title": f"Low stock: {product.name}",
"message": f"Only {product.stock} units remaining (SKU: {product.sku})",
"priority": 4 if product.stock == 0 else 3,
"tags": ["inventory", "low-stock",
"out-of-stock" if product.stock == 0 else "warning"],
},
)Failed payment alerts
async function onPaymentFailed(order, error) {
await fetch("https://app.alphorn.dev/api/webhooks/wh_abc123", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
title: `Payment failed: Order #${order.id}`,
message: `${error.message}\nCustomer: ${order.customerEmail}\nAmount: ${order.currency} ${order.total.toFixed(2)}`,
priority: 3,
tags: ["order", "payment-failed"],
}),
});
}Routing examples
| Channel | Filter | Purpose |
|---|---|---|
| Slack (#orders) | tags CONTAINS "new" | New order feed |
| Slack (#finance) | tags CONTAINS "refund" | Refund requests for finance team |
| Slack (#warehouse) | tags CONTAINS "inventory" | Stock alerts for warehouse |
| Telegram | tags CONTAINS "high-value" | Founder gets notified on big orders |
tags CONTAINS "order" | Full order archive | |
| PagerDuty | tags CONTAINS "out-of-stock" | Escalate sold-out products |