Channels

Channels

Send through a stable channel API while transports handle providers.

Choose a channel sender for the kind of message your application sends. Each sender accepts a provider transport, so delivery providers can change without rewriting send calls.

The one rule

Application code calls a sently channel sender; provider-specific code stays in its transport.
ChannelSenderSend shape
EmailcreateMailer or createSMTPMailerSender, recipient, subject, and body.
SMScreateSmsSenderRecipient number and body.
WhatsAppcreateWhatsAppSenderTemplate or text message.
PushcreatePushSenderWeb Push subscription or FCM token, plus title and body.
import { createSmsSender } from "sently/sms";
import { TwilioSmsTransport } from "sently/transports/twilio-sms";

const sms = createSmsSender({
  transport: new TwilioSmsTransport({
    accountSid: process.env.TWILIO_ACCOUNT_SID!,
    authToken: process.env.TWILIO_AUTH_TOKEN!,
  }),
});

await sms.send({
  to: "+15551234567",
  body: "Your order is on its way.",
  from: "+15557654321",
});

Channel factories

FactoryAsyncWhen to use it
createMailerYesEmail with an explicit transport.
createSMTPMailerYesEmail configured with SMTP host, port, and authentication.
createSmsSenderNoSMS with an SmsTransport.
createWhatsAppSenderNoWhatsApp with a WhatsAppTransport.
createPushSenderNoWeb Push or FCM with a PushTransport.

Troubleshooting

Learn more

Next

On this page