Channels

SMS

Send SMS through a sender and an SMS transport.

Use SMS for short transactional messages such as codes, delivery updates, and alerts. The sender stays the same when you change the provider transport.

The one rule

Put the recipient, body, and optional from value on sms.send, not on the shared sender.
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!,
  }),
});
const result = await sms.send({
  to: "+15551234567",
  body: "Your verification code is 482915.",
  from: "+15557654321",
});

console.log(result.status);

Sender configuration

OptionTypeMeaning
transportSmsTransportRequired provider delivery implementation.
pluginsSmsPlugin[]Optional transforms run before delivery.
hooksSmsHooksOptional callbacks for delivery activity.

Message options

OptionTypeMeaning
tostringRequired recipient number; E.164 is recommended.
bodystringRequired message text.
fromstringOptional sender number or alphanumeric sender ID.
messageIdstringOptional client-supplied identifier.

Twilio also accepts a default from or messagingServiceSid when you construct its concrete transport.

Troubleshooting

Learn more

Next

On this page