Skip to content
SMS SDK
Esc
↑↓navigate↵open⌘Jpreview
On this page

Examples

Runnable SMS SDK examples in the repository: a Twilio send, provider fallback, a webhook handler, and tests with the memory adapter.

The runnable examples live in packages/sms-sdk/examples, simplest first below. By default each one runs offline against a mocked provider API or the memory() adapter, so running them never sends a message. The test suite runs every example, which keeps them in step with the code.

Example Shows Docs
test-adapter App code tested with memory(), including a scripted compliance rejection. Local testing
twilio One send through Twilio. Mocked by default; opt into a live send with environment variables. Twilio
failover Twilio first, Telnyx after a known sender rejection, with handling for unknown outcomes. Retries and fallback
webhooks A plain fetch handler for Twilio and Telnyx webhooks: verification, deduplication, and a rejected forgery. Works with Bun.serve, Hono, and Next.js route handlers. Receiving overview

Run them

git clone https://github.com/opencoredev/sms-sdk.git
cd sms-sdk
bun install
cd packages/sms-sdk
bun examples/test-adapter/index.ts
bun examples/twilio/index.ts
bun examples/failover/index.ts
bun examples/webhooks/index.ts

Each prints what happened, such as twilio accepted SM0123456789abcdef0123456789abcdef (handoff accepted, delivery queued).

Send for real

Only the twilio example can send a real message, and only when you opt in. In packages/sms-sdk, copy .env.example to .env, fill in your Twilio credentials, and run:

SMS_EXAMPLE_LIVE=true SMS_EXAMPLE_TO=+14155550123 bun examples/twilio/index.ts

This sends one billable message to SMS_EXAMPLE_TO from TWILIO_FROM.