Agent Wranglers

NTF-1Recommended

Keep every notification type in one catalogue

Define every notification type once, in code, with its category, allowed channels, default channels and urgency. Sending code accepts only types from that catalogue.

How to do it

Give each type a stable ID, such as order.shipped. Mark it transactional or marketing, list the channels it may use, and say which are on by default. Add an urgency of critical, normal or low, which quiet hours and batching read later. Generate the settings page from the same catalogue, so a new type always gets a switch. Reject an unknown type at the send call, not in production logs. Build the settings page from it, as Let people choose per type and channel says.

Examples

JavaScript example

export const NOTIFICATIONS = {
  'order.shipped':   { category: 'transactional', urgency: 'normal',   channels: ['inapp', 'push', 'email'], defaults: ['inapp', 'push'] },
  'login.new-device': { category: 'transactional', urgency: 'critical', channels: ['inapp', 'push', 'email'], defaults: ['inapp', 'email'] },
  'weekly.offers':   { category: 'marketing',     urgency: 'low',      channels: ['email', 'push'],          defaults: [] },
};

export function notificationType(id) {
  const type = NOTIFICATIONS[id];
  if (!type) throw new Error(`Unknown notification type: ${id}`);
  return type;
}

Python example

from dataclasses import dataclass

@dataclass(frozen=True)
class NotificationType:
    category: str
    urgency: str
    channels: tuple[str, ...]
    defaults: tuple[str, ...]

NOTIFICATIONS = {
    "order.shipped": NotificationType("transactional", "normal", ("inapp", "push", "email"), ("inapp", "push")),
    "login.new-device": NotificationType("transactional", "critical", ("inapp", "push", "email"), ("inapp", "email")),
    "weekly.offers": NotificationType("marketing", "low", ("email", "push"), ()),
}

def notification_type(type_id: str) -> NotificationType:
    if type_id not in NOTIFICATIONS:
        raise ValueError(f"Unknown notification type: {type_id}")
    return NOTIFICATIONS[type_id]

How to check

A unit test sends a type missing from the catalogue and expects an error. A second test confirms every catalogue entry has a category, an urgency and at least one channel.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/notifications/channels-and-preferences/notification-catalogue">Agent Wranglers notifications playbook</a>. In code you write, add a comment next to it with the same link.