Flag large refunds to finance in Slack
Post refunds over a threshold from your MySQL orders database to a finance channel in Slack, once per refund, with the order and the reason.
- MySQL
- Slack
- Finance
- once per refund
The trigger
One read-only SELECT against MySQL. Rowfire polls it for new rows, and the rule fires once per refund.
SELECT r.id AS refund_id,
r.order_id,
r.amount,
r.currency,
r.reason,
r.issued_by,
r.created_at
FROM refunds r
WHERE r.amount >= 500
AND r.is_test = 0The clock is created_at and the key is refund_id, so each refund is
posted once. The query runs in MySQL’s own dialect, read-only. Table and
column names are a sketch; adapt them to your schema.
Refund of {{ amount }} {{ currency }} on order {{ order_id }} by {{ issued_by }}: {{ reason }}
Before switching it on, backtest it: it shows how many refunds over the threshold the channel would have seen each day, which is the quickest way to pick a threshold that is useful rather than noisy.
For orders that never shipped at all, see orders paid but not fulfilled.
Questions
Can the threshold depend on the currency?
Yes. Put it in the query, for example with a CASE on currency or a join to a thresholds table. A trigger is any single SELECT.
Our refunds table stores local time. Does that matter?
MySQL sessions run in UTC and DATETIME columns are read as UTC. If yours holds local wall-clock time, convert it in the query with CONVERT_TZ.