National Commerce Docs
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

  1. It validates the payload (total_label_cost > 0) and that shipping_threshold_exceeded is true.
  2. It reads the order, its shipments, and the brand token, then Check ShipHero Units sums the true units shipped across shipments, failing open (send) on any token, API, or data uncertainty.
  3. Compute Verdict recomputes a per-unit-corrected threshold (stored threshold × trueUnits/dbQty) and suppresses the email only if the label cost is within it.
  4. Guards check that the threshold is still exceeded, the order is within the last 7 days, and shipping_threshold_exceeded_notification_sent is not yet set.
  5. It loads brand users (excluding revoked) and loops each; if send_notifications and fulfillment.shipping_cost_alert are both true, it fetches the email via the Supabase Admin API and sends a branded HTML alert via Gmail.
  6. 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.

On this page