n8n flows
Notify: Shipment Cost Exceeded
Emails brand users when an order's actual shipping-label cost exceeds its postage threshold, with a ShipHero unit-count guard against false positives.
This flow emails brand users when an order's actual shipping label cost exceeds its postage threshold. A fail-open ShipHero unit-count guard suppresses false positives, and a dedupe flag makes each order alert only once.
At a glance
- Status: Inactive.
- Trigger: Webhook ("When The Order Shipping Is Too High..."), intended to be fired by a Supabase DB trigger on the Orders record.
- Runs on: A single order per call.
- Talks to: Supabase, ShipHero GraphQL, and Gmail.
How it works
- It validates the payload (
total_label_cost > 0) and thatshipping_threshold_exceededis true. - It reads the order, its shipments, and the brand token, then
Check ShipHero Unitssums the true units shipped across shipments, failing open (send) on any token, API, or data uncertainty. Compute Verdictrecomputes a per-unit-corrected threshold (stored threshold × trueUnits/dbQty) and suppresses the email only if the label cost is within it.- Guards check that the threshold is still exceeded, the order is within the last 7 days, and
shipping_threshold_exceeded_notification_sentis not yet set. - It loads brand users (excluding revoked) and loops each; if
send_notificationsandfulfillment.shipping_cost_alertare both true, it fetches the email via the Supabase Admin API and sends a branded HTML alert via Gmail. - It sets the sent flag, stores the order number in execution custom data, and returns
200 OK.
Notes
- The two-layer fail-open design (ShipHero unit reconciliation) prevents spurious alerts when Supabase quantities are stale. When in doubt, it sends.
- Currently disabled. Per-user opt-in is respected on two preference flags.
Related
- Missing Shipment Data Pull 2.0 (Backup) populates the shipments and label costs this flow checks.
- Error Handler: the shared error workflow.
- Features: Shipments covers Price Alerts and how the postage threshold works. See also Data flows.