Agent Wranglers

Channels and preferences Required

Let people choose per type and channel

Let each person turn every notification type on or off per channel, and read those choices at send time.

How to do it

Store one row per user, type and channel only when it differs from the catalogue default. Read the row when the message is sent, not when it is queued, so a change applies at once. Security notices, such as a new sign-in, may stay on for at least one channel, but say so on the settings page. Offer a link to the settings page in every message, next to the email preference centre.

Example

export async function channelsFor(userId, typeId) {
  const type = notificationType(typeId);
  const overrides = await db.preferences.forUserAndType(userId, typeId); // Map of channel to on or off
  return type.channels.filter(channel => overrides.get(channel) ?? type.defaults.includes(channel));
}
def channels_for(user_id: str, type_id: str) -> list[str]:
    kind = notification_type(type_id)
    overrides = db.preferences_for(user_id, type_id)  # dict of channel to bool
    return [c for c in kind.channels if overrides.get(c, c in kind.defaults)]

How to check

Turn off push for order.shipped and trigger a shipment. In-app shows it and no push is sent. Turn it on again and the next shipment pushes.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers notifications playbook: https://agentwranglers.se/playbook/notifications/channels-and-preferences/notification-preferences.