Adds a payload.sendSMS method backed by a provider adapter interface, with each provider shipped as a separate subpath export and its SDK as an optional peer dependency. It can create an sms-logs collection, show a dashboard widget and receive delivery-status webhooks. It targets Payload 3.x and requires recipient numbers in E.164 format.
Multi-provider SMS plugin for Payload CMS 3.x with Twilio, Telnyx, Plivo, Vonage, and AWS SNS adapters.
Installation
npm i @elghaied/payload-plugin-sms7
Stars
0
Forks
0
Open Issues
5 months ago
Last Updated
81
Weekly Downloads
v0.5.0
npm Version
558.5 KB
Unpacked Size
0
Dependencies
7+2 since Sep 6
| Date | Stars |
|---|---|
| Dec 5, 2026 | 7 |
| Dec 4, 2026 | 7 |
| Dec 3, 2026 | 7 |
| Dec 2, 2026 | 7 |
| Dec 1, 2026 | 7 |
| Nov 30, 2026 | 7 |
| Nov 29, 2026 | 7 |
| Nov 28, 2026 | 7 |
| Nov 27, 2026 | 7 |
| Nov 26, 2026 | 7 |
| Nov 25, 2026 | 7 |
| Nov 24, 2026 | 7 |
| Nov 23, 2026 | 7 |
| Nov 22, 2026 | 7 |
| Nov 21, 2026 | 7 |
| Nov 20, 2026 | 7 |
| Nov 19, 2026 | 7 |
| Nov 18, 2026 | 7 |
| Nov 17, 2026 | 7 |
| Nov 16, 2026 | 7 |
| Nov 15, 2026 | 7 |
| Nov 14, 2026 | 7 |
| Nov 13, 2026 | 7 |
| Nov 12, 2026 | 7 |
| Nov 11, 2026 | 7 |
| Nov 10, 2026 | 7 |
| Nov 9, 2026 | 7 |
| Nov 8, 2026 | 7 |
| Nov 7, 2026 | 7 |
| Nov 6, 2026 | 7 |
| Nov 5, 2026 | 7 |
| Nov 4, 2026 | 7 |
| Nov 3, 2026 | 7 |
| Nov 2, 2026 | 7 |
| Nov 1, 2026 | 7 |
| Oct 31, 2026 | 7 |
| Oct 30, 2026 | 7 |
| Oct 29, 2026 | 7 |
| Oct 28, 2026 | 7 |
| Oct 27, 2026 | 7 |
| Oct 26, 2026 | 7 |
| Oct 25, 2026 | 7 |
| Oct 24, 2026 | 7 |
| Oct 23, 2026 | 7 |
| Oct 22, 2026 | 7 |
| Oct 21, 2026 | 7 |
| Oct 20, 2026 | 7 |
| Oct 19, 2026 | 7 |
| Oct 18, 2026 | 7 |
| Oct 17, 2026 | 7 |
| Oct 16, 2026 | 7 |
| Oct 15, 2026 | 7 |
| Oct 14, 2026 | 7 |
| Oct 13, 2026 | 7 |
| Oct 12, 2026 | 7 |
| Oct 11, 2026 | 7 |
| Oct 10, 2026 | 7 |
| Oct 9, 2026 | 6 |
| Oct 8, 2026 | 6 |
| Oct 7, 2026 | 6 |
| Oct 6, 2026 | 6 |
| Oct 5, 2026 | 6 |
| Oct 4, 2026 | 6 |
| Oct 3, 2026 | 6 |
| Oct 2, 2026 | 6 |
| Oct 1, 2026 | 6 |
| Sep 30, 2026 | 6 |
| Sep 29, 2026 | 6 |
| Sep 28, 2026 | 6 |
| Sep 27, 2026 | 6 |
| Sep 26, 2026 | 5 |
| Sep 25, 2026 | 5 |
| Sep 24, 2026 | 5 |
| Sep 23, 2026 | 5 |
| Sep 22, 2026 | 5 |
| Sep 21, 2026 | 5 |
| Sep 20, 2026 | 5 |
| Sep 19, 2026 | 5 |
| Sep 18, 2026 | 5 |
| Sep 17, 2026 | 5 |
| Sep 16, 2026 | 5 |
| Sep 15, 2026 | 5 |
| Sep 14, 2026 | 5 |
| Sep 13, 2026 | 5 |
| Sep 12, 2026 | 5 |
| Sep 11, 2026 | 5 |
| Sep 10, 2026 | 5 |
| Sep 9, 2026 | 5 |
| Sep 8, 2026 | 5 |
| Sep 7, 2026 | 5 |
| Sep 6, 2026 | 5 |
64−3 since Sep 6
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 64 |
| Dec 4, 2026 | 83 |
| Dec 3, 2026 | 84 |
| Dec 2, 2026 | 87 |
| Dec 1, 2026 | 80 |
| Nov 30, 2026 | 77 |
| Nov 29, 2026 | 70 |
| Nov 28, 2026 | 69 |
| Nov 27, 2026 | 53 |
| Nov 26, 2026 | 50 |
| Nov 25, 2026 | 58 |
| Nov 24, 2026 | 54 |
| Nov 23, 2026 | 45 |
| Nov 22, 2026 | 54 |
| Nov 21, 2026 | 56 |
| Nov 20, 2026 | 59 |
| Nov 19, 2026 | 69 |
| Nov 18, 2026 | 77 |
| Nov 17, 2026 | 79 |
| Nov 16, 2026 | 90 |
| Nov 15, 2026 | 79 |
| Nov 14, 2026 | 80 |
| Nov 13, 2026 | 73 |
| Nov 12, 2026 | 60 |
| Nov 11, 2026 | 47 |
| Nov 10, 2026 | 47 |
| Nov 9, 2026 | 36 |
| Nov 8, 2026 | 36 |
| Nov 7, 2026 | 40 |
| Nov 6, 2026 | 37 |
| Nov 5, 2026 | 36 |
| Nov 4, 2026 | 29 |
| Nov 3, 2026 | 31 |
| Nov 2, 2026 | 30 |
| Nov 1, 2026 | 26 |
| Oct 31, 2026 | 19 |
| Oct 30, 2026 | 27 |
| Oct 29, 2026 | 24 |
| Oct 28, 2026 | 23 |
| Oct 27, 2026 | 25 |
| Oct 26, 2026 | 27 |
| Oct 25, 2026 | 44 |
| Oct 24, 2026 | 64 |
| Oct 23, 2026 | 55 |
| Oct 22, 2026 | 73 |
| Oct 21, 2026 | 88 |
| Oct 20, 2026 | 90 |
| Oct 19, 2026 | 97 |
| Oct 18, 2026 | 90 |
| Oct 17, 2026 | 78 |
| Oct 16, 2026 | 94 |
| Oct 15, 2026 | 89 |
| Oct 14, 2026 | 92 |
| Oct 13, 2026 | 87 |
| Oct 12, 2026 | 82 |
| Oct 11, 2026 | 76 |
| Oct 10, 2026 | 74 |
| Oct 9, 2026 | 69 |
| Oct 8, 2026 | 59 |
| Oct 7, 2026 | 43 |
| Oct 6, 2026 | 38 |
| Oct 5, 2026 | 36 |
| Oct 4, 2026 | 39 |
| Oct 3, 2026 | 36 |
| Oct 2, 2026 | 29 |
| Oct 1, 2026 | 28 |
| Sep 30, 2026 | 33 |
| Sep 29, 2026 | 45 |
| Sep 28, 2026 | 55 |
| Sep 27, 2026 | 59 |
| Sep 26, 2026 | 74 |
| Sep 25, 2026 | 72 |
| Sep 24, 2026 | 100 |
| Sep 23, 2026 | 99 |
| Sep 22, 2026 | 84 |
| Sep 21, 2026 | 76 |
| Sep 20, 2026 | 73 |
| Sep 19, 2026 | 65 |
| Sep 18, 2026 | 76 |
| Sep 17, 2026 | 78 |
| Sep 16, 2026 | 90 |
| Sep 15, 2026 | 96 |
| Sep 14, 2026 | 93 |
| Sep 13, 2026 | 98 |
| Sep 12, 2026 | 104 |
| Sep 11, 2026 | 99 |
| Sep 10, 2026 | 78 |
| Sep 9, 2026 | 70 |
| Sep 8, 2026 | 70 |
| Sep 7, 2026 | 70 |
| Sep 6, 2026 | 67 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1249769132-root)<a href="https://payloaddirectory.dev/plugins/1249769132-root"><img src="https://payloaddirectory.dev/badge/1249769132-root.svg" alt="Payload Directory"></a>README
Multi-provider SMS plugin for Payload CMS 3.x. Send SMS through Twilio, Telnyx, Plivo, Vonage, or AWS SNS — and call payload.sendSMS(...) from anywhere.
Architecture mirrors @payloadcms/email-nodemailer: a thin core defines an adapter interface, and each provider ships as a separate subpath export with the SDK declared as an optional peer dependency.
pnpm add @elghaied/payload-plugin-sms
Then install the SDK for your chosen provider:
pnpm add twilio # Twilio
pnpm add telnyx # Telnyx
pnpm add plivo # Plivo
pnpm add @vonage/server-sdk # Vonage
pnpm add @aws-sdk/client-sns # AWS SNS
import { buildConfig } from 'payload'
import { smsPlugin } from '@elghaied/payload-plugin-sms'
import { twilioAdapter } from '@elghaied/payload-plugin-sms/twilio'
export default buildConfig({
plugins: [
smsPlugin({
adapter: twilioAdapter({
accountSid: process.env.TWILIO_ACCOUNT_SID!,
authToken: process.env.TWILIO_AUTH_TOKEN!,
defaultFrom: process.env.TWILIO_FROM!,
}),
collections: { logs: true },
widgets: true,
}),
],
})
import type { CollectionConfig } from 'payload'
export const Users: CollectionConfig = {
slug: 'users',
auth: true,
fields: [{ name: 'phone', type: 'text' }],
hooks: {
afterChange: [
async ({ doc, req, operation }) => {
if (operation === 'create' && doc.phone) {
await req.payload.sendSMS({
to: doc.phone,
body: `Welcome ${doc.email}!`,
})
}
},
],
},
}
to must be E.164 (+ then 1–15 digits). from falls back to plugin defaultFrom, then adapter defaultFrom.
import { twilioAdapter } from '@elghaied/payload-plugin-sms/twilio'
twilioAdapter({
accountSid: '...',
authToken: '...',
defaultFrom: '+15551234567',
messagingServiceSid: 'MG...', // optional; supersedes `from`
})
import { telnyxAdapter } from '@elghaied/payload-plugin-sms/telnyx'
telnyxAdapter({
apiKey: '...',
defaultFrom: '+15551234567',
messagingProfileId: '...', // optional
})
import { plivoAdapter } from '@elghaied/payload-plugin-sms/plivo'
plivoAdapter({
authId: '...',
authToken: '...',
defaultFrom: '+15551234567',
})
Uses the legacy SMS API (key + secret). The Messages API (JWT-authenticated) is on the roadmap.
import { vonageAdapter } from '@elghaied/payload-plugin-sms/vonage'
vonageAdapter({
apiKey: '...',
apiSecret: '...',
defaultFrom: '+15551234567',
})
SNS has no per-message from. defaultFrom is sent as the AWS.SNS.SMS.SenderID attribute (region-dependent support).
import { awsSnsAdapter } from '@elghaied/payload-plugin-sms/aws-sns'
awsSnsAdapter({
region: 'us-east-1',
credentials: { // optional; falls back to default AWS credential chain
accessKeyId: '...',
secretAccessKey: '...',
},
defaultFrom: 'MYBRAND', // sender ID
smsType: 'Transactional', // or 'Promotional'
})
import { mockAdapter } from '@elghaied/payload-plugin-sms/mock'
const adapter = mockAdapter({ defaultFrom: '+15550000000' })
adapter.messages // array of sent messages
adapter.reset() // clears it
| Option | Type | Default | Notes |
|---|---|---|---|
adapter | SMSAdapter | — | Required at runtime. Missing adapter → sendSMS throws. |
defaultFrom | string | — | Falls back to adapter's defaultFrom. |
disabled | boolean | false | Skips registration; logs a warning. |
collections.logs | boolean | { slug?; admin?; includeContext?; statusHistory? } | false | Creates an sms-logs collection. includeContext adds a JSON context field; statusHistory adds an append-only status-event array. |
widgets | boolean | true | Registers the dashboard widget when logs enabled. |
tenantScoping | { field?: string; cookie?: string } | — (off) | Opt-in. Scopes the dashboard widget to the host's selected tenant. See Dashboard widget. |
webhooks | { enabled; basePath?; statusCallbackUrl?; trustProxy?; verifySignature? } | — | Enables the delivery-status receiver + auto-derived callback. See Delivery-status webhooks. |
onSend | (args) => void | Promise<void> | — | Called after every successful send. |
onError | (args) => void | Promise<void> | — | Called when send fails. Original error is re-thrown. |
onStatus | (args) => void | Promise<void> | — | Called on every delivery-status webhook event (requires webhooks.enabled). |
Enable with collections: { logs: true }. Schema:
| Field | Type | Notes |
|---|---|---|
to | text | Recipient |
from | text | Sender |
body | textarea | Message body |
provider | text | Adapter name |
status | select | queued/sent/delivered/failed/unknown |
providerMessageId | text | Provider's message id |
cost | group | { amount, currency } when reported |
error | textarea | Adapter error message (if any) |
errorCode | text | Provider error code (from a failed-status webhook) |
sentAt | date | Server timestamp |
deliveredAt | date | Set when a webhook reports delivered |
failedAt | date | Set when a webhook reports failed |
context | json | Per-send metadata — only with includeContext: true |
statusHistory | array | Append-only { status, occurredAt, errorCode } — only with statusHistory: true |
deliveredAt / failedAt / errorCode / statusHistory are populated by delivery-status webhooks.
Read access requires a logged-in admin user. Create/update/delete from the admin panel are blocked — the plugin is the only writer.
Override the slug:
collections: { logs: { slug: 'audit-sms', admin: { group: 'Audit' } } }
Note: if you override the slug, set widgets: false — the bundled widget reads from sms-logs only.
When widgets: true and logs are enabled, the plugin registers an admin.dashboard.widgets entry that shows a 24h send count, the last 5 entries, and a link to the logs collection.
Disable with widgets: false.
The plugin is single-tenant by design, so by default the widget queries sms-logs with the Local API's implicit overrideAccess: true and no tenant filter — it shows every row. In a multi-tenant host (e.g. @payloadcms/plugin-multi-tenant injecting a tenant field into sms-logs) that leaks other tenants' logs into the dashboard.
Opt in with tenantScoping to make the widget honor the host's tenant selector:
smsPlugin({
adapter,
collections: { logs: true },
tenantScoping: { field: 'tenant', cookie: 'payload-tenant' }, // both optional; these are the defaults
})
When enabled and the logs collection actually has the configured field, the widget:
cookie and adds where[field][equals]=<id> to both the 24h count and the recent-5 list, andoverrideAccess: false and the real request/user, so any read access control the host added to sms-logs is respected.With no tenant selected ("all tenants"), it drops the tenant filter but still runs with overrideAccess: false, so the dashboard shows everything the current user is allowed to read. Omit tenantScoping, or leave the field off the collection, and the widget behaves exactly as before.
For multi-tenant SaaS or geo-routing, wrap multiple adapters in a routerAdapter and decide per-send which one handles the message.
import { smsPlugin } from '@elghaied/payload-plugin-sms'
import { twilioAdapter } from '@elghaied/payload-plugin-sms/twilio'
import { telnyxAdapter } from '@elghaied/payload-plugin-sms/telnyx'
import { routerAdapter, byTenantLookup } from '@elghaied/payload-plugin-sms/router'
smsPlugin({
adapter: routerAdapter({
providers: {
twilio: twilioAdapter({ accountSid, authToken }),
telnyx: telnyxAdapter({ apiKey }),
},
route: byTenantLookup({
collection: 'tenants',
providerField: 'smsProvider',
cacheMs: 60_000,
}),
}),
collections: { logs: { includeContext: true } },
})
At the call site, attach the tenant id (and any per-tenant from):
await req.payload.sendSMS({
to: customer.phone,
from: tenant.smsFromNumber,
body: '...',
context: { tenantId: tenant.id },
})
The router is just another SMSAdapter. Single-provider users (smsPlugin({ adapter: twilioAdapter(...) })) are unaffected.
| Helper | Use |
|---|---|
byTenantLookup({ collection, providerField, contextKey?, cacheMs?, fallback? }) | SaaS: read tenant id from message.context, fetch the doc, return its provider field |
byCountryPrefix({ '+1': 'twilio', '+33': 'telnyx' }, { fallback? }) | Geo route by E.164 prefix; longest-prefix wins |
byRoundRobin(['twilio-a', 'twilio-b']) | Cycle across duplicate accounts |
byRandom(['twilio-a', 'twilio-b']) | Uniform random pick |
withFailover(inner, ['fallback-a', 'fallback-b']) | Wrap any route; on SMSProviderError, try the next provider in order |
You can also write a route callback directly — it's just (args) => string \| string[] (or async).
contextSMSMessage.context is an opaque per-send map. It flows to the route function, the onSend/onError hooks (via args.message), and — when collections.logs.includeContext: true — into a context (JSON) field on the sms-logs collection.
A route returning a single provider name calls that provider once. Returning an array ['a', 'b'] tries each in order on SMSProviderError; if all fail the router throws a single SMSProviderError whose .cause is an array of the individual errors. SMSValidationError is never retried.
smsPlugin({
adapter: twilioAdapter({ ... }),
onSend: async ({ result, req }) => {
console.log(`Sent ${result.id} via ${result.provider} to ${result.to}`)
},
onError: async ({ error, message, req }) => {
console.error(`Failed to send to ${message.to}:`, error)
},
})
Hook failures are logged but do not affect the SMS send result. req is undefined when called via payload.sendSMS (Payload's local API does not thread req through dynamic methods).
import { SMSValidationError, SMSProviderError } from '@elghaied/payload-plugin-sms'
try {
await payload.sendSMS({ to: 'not-e164', body: 'hi' })
} catch (err) {
if (err instanceof SMSValidationError) {
// Bad input (E.164 fail, missing from, missing adapter)
} else if (err instanceof SMSProviderError) {
// Adapter call failed; `err.cause` has the original SDK error
}
}
Enable provider webhooks to keep sms-logs rows in sync with real delivery state. With webhooks: { enabled: true }, the Twilio/Telnyx/Plivo adapters are also handed a per-message delivery-status callback URL automatically — derived from config.serverURL + the webhook base path (e.g. https://app.com/api/sms/webhooks/twilio). No Messaging-Service or provider-portal step is required for a plain sender. (Vonage and AWS SNS have no per-message callback and are unaffected.)
import { smsPlugin } from '@elghaied/payload-plugin-sms'
import { twilioAdapter } from '@elghaied/payload-plugin-sms/twilio'
export default buildConfig({
// ...
plugins: [
smsPlugin({
adapter: twilioAdapter({
accountSid: process.env.TWILIO_ACCOUNT_SID!,
authToken: process.env.TWILIO_AUTH_TOKEN!,
defaultFrom: process.env.TWILIO_FROM,
webhook: { trustProxy: true }, // optional, if behind a proxy
}),
collections: { logs: { statusHistory: true } },
webhooks: { enabled: true },
onStatus: ({ event, log }) => {
// optional: notify your app on every status transition
},
}),
],
})
Webhook URLs (Payload prepends /api):
| Provider | URL | Required adapter webhook opts |
|---|---|---|
| Twilio | /api/sms/webhooks/twilio | (none — uses authToken) |
| Telnyx | /api/sms/webhooks/telnyx | publicKey (Ed25519 PEM, from Telnyx portal) |
| Plivo | /api/sms/webhooks/plivo | (none — uses authToken) |
| Vonage | /api/sms/webhooks/vonage | signatureSecret, signatureMethod: 'sha256hash' | 'sha512hash' |
| AWS SNS | /api/sms/webhooks/aws-sns | (none — verified via SigningCertURL; auto-confirms SubscriptionConfirmation) |
Notes:
serverURL is missing or points at localhost/127.0.0.1 (dev). Override it with webhooks.statusCallbackUrl (applies to Twilio/Telnyx/Plivo).webhook: { trustProxy: true } so the host/protocol are read from forwarded headers — or use the webhooks.statusCallbackUrl override to pin both ends explicitly.webhooks.verifySignature: false only for local testing.queued → sent → delivered, with failed terminal), so out-of-order or duplicate webhooks are dropped silently.collections.logs.statusHistory: true to keep an append-only history of every event.sha256hash or sha512hash.The sms-logs collection (labels, field labels, status options) and the dashboard widget ship with bundled en and fr translations, deep-merged into config.i18n.translations under an sms namespace. Your existing translations always win on conflict.
Override any string — or add a language — via i18n.translations.{lang}.sms:
buildConfig({
i18n: {
translations: {
fr: { sms: { fieldTo: 'Destinataire' } },
// add a new language by supplying its sms.* keys
},
},
// ...
})
The raw translation tables are also available directly via the @elghaied/payload-plugin-sms/translations export.
PRs welcome.
^3.0.0 (tested against 3.84.1)^16.0.0^18.20.2 || >=20.9.0@elghaied/payload-plugin-sms/rsc).MIT
payload plugin notifications
In-site notices with per-kind email copies, user preferences and a retrying send queue
74127/wk0v3
payload notifications
Notifications collection with channels, per-user subscriptions, read state and optional web push delivery
67141/wk1v3
smstunnel payload
Send SMS from Payload hooks, endpoints and jobs through your own Android phone and number
6417/wk0v3
payload plugin notifications
In-dashboard notifications for the Payload admin with a live bell that updates over server-sent events
469/wk7v3
telegram
Send Telegram messages when Payload form builder forms are submitted, with optional UTM data
76499/wk0v4
payload plugin comments
Document-level and field-level comments with mentions, resolution and email notifications for Payload admin
757.0k/wk37v3