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

Examples

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

The runnable examples live in packages/sms-sdk/examples. 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 Read next
test-adapter App code tested with memory(), including a scripted compliance rejection. Test without a provider
twilio One send through Twilio. Mocked unless you opt into a live send. Twilio
failover Twilio first, Telnyx after a known sender rejection, with handling for unknown outcomes. Fallback and retries
webhooks A plain fetch handler for Twilio and Telnyx webhooks: verification, deduplication, and a rejected forgery. It works with Bun.serve, Hono, and Next.js route handlers. Webhooks

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. The Twilio example prints 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 TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, and TWILIO_FROM, then 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.