Rules for Shipment Notifications

Karl Falconer ·

The Shipment Notification hook fires when tracking information arrives from a fulfillment provider, just before DropStream sends a notification to the customer or back to the sales channel. Unlike the import hooks, this one exposes two records: the shipment itself and the parent order it came from.

That parent-order access is the heart of these recipes — most shipment-notification rules check something on the order to decide whether or how to send the notification.

Suppress notifications for internal transfers

rule "Suppress internal transfer notifications"
  when
    order.customer_email ends_with "@yourcompany.com"
    or order.notes contains "INTERNAL"
  then
    reject shipment
  end
end

Internal transfers don’t need customer-facing notifications. Rejecting the shipment in this hook prevents the notification from being sent — the shipment itself is unaffected.

Suppress when the order has no email

rule "Don't notify customers without email"
  when
    order.customer_email is blank
  then
    reject shipment
  end
end

A common defensive pattern: if there’s no customer email, there’s nothing to send.

Add country-specific tracking message

rule "International tracking message"
  when
    order.shipping_address.country is_not "US"
    and order.shipping_address.country is_not blank
  then
    set shipment.custom.notification_message to
      "International shipment to " & order.shipping_address.country
      & ". Customs delays may apply."
  end
end

International orders get a different message than domestic ones. The condition checks both that the country isn’t US and that it isn’t blank — important for orders where the country didn’t import correctly.

Route notification through a specific channel

rule "Route VIP notifications through priority channel"
  when
    order.custom.tier is "vip"
    or order.subtotal > 1000.0
  then
    set shipment.custom.notification_channel to "priority"
  end
end

If your notification system supports multiple channels (priority email, SMS, etc.), use the parent order’s data to pick which channel to route through.

Tag shipments by carrier

rule "Tag shipments by carrier"
  when
    shipment.tracking_number matches /^1Z[A-Z0-9]{16}$/
  then
    set shipment.custom.detected_carrier to "UPS"
  end

  when
    shipment.tracking_number matches /^\d{12}$/
  then
    set shipment.custom.detected_carrier to "FedEx"
  end

  when
    shipment.tracking_number matches /^9[0-9]{15,21}$/
  then
    set shipment.custom.detected_carrier to "USPS"
  end
end

Tracking-number patterns identify the carrier. DropStream may already do some of this, but you can add or override based on your specific carrier mix.

Hold notifications until business hours

rule "Hold notifications outside business hours"
  timezone "Eastern Time (US & Canada)"

  when
    @now is_on @saturday
    or @now is_on @sunday
  then
    hold shipment until @monday at @T09:00:00
  end

  when
    @now < @T09:00:00
    or @now > @T17:00:00
  then
    hold shipment waiting 1h
  end
end

Customer notifications outside of business hours can be deferred. Note the use of @now for current-time comparisons.

Add order context to notifications

rule "Add order context to notification"
  set shipment.custom.notification_message to
    "Your order #" & order.id
    & " (" & order.customer_email & ")"
    & " has shipped via " & shipment.carrier_name
    & ". Tracking: " & shipment.tracking_number
end

A complete notification message built by combining shipment fields and order fields — exactly what the cross-model access of this hook is designed for.

Suppress for low-value shipments

rule "Skip notification for shipments under $50"
  accumulate shipment_lines in shipment
    shipment_value: sum shipment_line.unit_price * shipment_line.quantity
  end

  when shipment_value < 50.0 then
    reject shipment
  end
end

You might want to skip customer notifications for very small shipments — for instance, accessory replacements that follow a larger main order. The threshold is up to you.

Tips

  • You can read both records. The unique value of this hook is the parent order. Use order.X for customer details, totals, tags set by Order Import rules. Use shipment.X for tracking info and carrier details.
  • Rejecting the shipment skips the notification. It does not prevent the shipment itself from going out — the shipment was already sent by the warehouse. Reject just stops DropStream from sending its notification about it.
  • Set tags or fields, don’t transform critical data. The shipment record is what your sales channel sees post-shipment. Be conservative about what you change here — set tags and notification fields, but be careful with anything that affects fulfillment status.
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.