NotificationRouting

Routing

Channel fallback, broadcast, provider failover and round-robin

Routing

There are two independent axes of routing.

Provider-within-channel

Wrap several same-channel providers:

import { failoverProvider } from "@visulima/notification/providers/failover";
import { roundRobinProvider } from "@visulima/notification/providers/roundrobin";

const sms = failoverProvider([twilioProvider({ … }), vonageProvider({ … })]); // try in order
const balanced = roundRobinProvider([plivoProvider({ … }), telnyxProvider({ … })]); // rotate (falls over by default)

const notify = createNotification({ sms });

Channel-sequence routing

route(...) delivers across channels with a priority order and an optional gate.

import { route } from "@visulima/notification/routing";

// best-of (default): try sms, then push, then email — stop at the first success
await route(notify, message, { order: ["sms", "push", "email"], mode: "best-of" });

// all: broadcast to every present channel in parallel
await route(notify, message, { mode: "all" });

Gating

A gate runs before each channel and skips it when it returns false. Use it for preferences, capability checks or send-windows.

await route(notify, message, {
    gate: (channel, payload) => channel !== "sms" || isWithinQuietHours() === false,
});

See Preferences for a ready-made preference gate.

Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues