Adds server-side helpers that hand each text to your SMSTunnel account, and your linked Android phone sends it from its own SIM. It registers through the plugins array, adds no collections or endpoints, and stores settings in config.custom. Requires Payload 3, an SMSTunnel API key and the SMSTunnel app on an Android phone.
SMSTunnel for Payload CMS 3: send texts from hooks, endpoints and jobs through your own Android phone, from your own number.
Installation
npm i @narcisbodea/smstunnel-payload0
Stars
0
Forks
0
Open Issues
1 months ago
Last Updated
17
Weekly Downloads
v1.0.0
npm Version
51.4 KB
Unpacked Size
0
Dependencies
00 since Nov 1
| Date | Stars |
|---|---|
| Dec 6, 2026 | 0 |
| Dec 5, 2026 | 0 |
| Dec 4, 2026 | 0 |
| Dec 3, 2026 | 0 |
| Dec 2, 2026 | 0 |
| Dec 1, 2026 | 0 |
| Nov 30, 2026 | 0 |
| Nov 29, 2026 | 0 |
| Nov 28, 2026 | 0 |
| Nov 27, 2026 | 0 |
| Nov 26, 2026 | 0 |
| Nov 25, 2026 | 0 |
| Nov 24, 2026 | 0 |
| Nov 23, 2026 | 0 |
| Nov 22, 2026 | 0 |
| Nov 21, 2026 | 0 |
| Nov 20, 2026 | 0 |
| Nov 19, 2026 | 0 |
| Nov 18, 2026 | 0 |
| Nov 17, 2026 | 0 |
| Nov 16, 2026 | 0 |
| Nov 15, 2026 | 0 |
| Nov 14, 2026 | 0 |
| Nov 13, 2026 | 0 |
| Nov 12, 2026 | 0 |
| Nov 11, 2026 | 0 |
| Nov 10, 2026 | 0 |
| Nov 9, 2026 | 0 |
| Nov 8, 2026 | 0 |
| Nov 7, 2026 | 0 |
| Nov 6, 2026 | 0 |
| Nov 5, 2026 | 0 |
| Nov 4, 2026 | 0 |
| Nov 3, 2026 | 0 |
| Nov 2, 2026 | 0 |
| Nov 1, 2026 | 0 |
21+21 since Nov 21
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 21 |
| Dec 5, 2026 | 26 |
| Dec 4, 2026 | 27 |
| Dec 3, 2026 | 29 |
| Dec 2, 2026 | 28 |
| Dec 1, 2026 | 43 |
| Nov 30, 2026 | 43 |
| Nov 29, 2026 | 66 |
| Nov 28, 2026 | 267 |
| Nov 27, 2026 | 264 |
| Nov 26, 2026 | 260 |
| Nov 25, 2026 | 258 |
| Nov 24, 2026 | 241 |
| Nov 23, 2026 | 236 |
| Nov 22, 2026 | 206 |
| Nov 21, 2026 | 0 |
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/1444817755-root)<a href="https://payloaddirectory.dev/plugins/1444817755-root"><img src="https://payloaddirectory.dev/badge/1444817755-root.svg" alt="Payload Directory"></a>README
@narcisbodea/smstunnel-payload: send texts from your Payload 3 hooks, endpoints and jobs through your own Android phone, from your own number, with SMSTunnel.
Payload hands each text to your SMSTunnel account, and your phone sends it from its own SIM, so people see a number they know and can reply to. No SMS provider account and no sender registration: the phone runs the SMSTunnel app and is linked to your account.
SMSTunnel for Payload is made by NARBOWEB SRL. It is not affiliated with, endorsed by, or sponsored by Payload (payloadcms.com).
npm install @narcisbodea/smstunnel-payload
Payload 3 (tested with 3.92.1), server side only. No other dependencies.
Put it in your environment (.env, or your host's secret settings), never in your code:
SMSTUNNEL_API_KEY=sk_live_...
Add the plugin to payload.config.ts:
import { buildConfig } from 'payload'
import { smsTunnelPlugin } from '@narcisbodea/smstunnel-payload'
export default buildConfig({
// ...
plugins: [smsTunnelPlugin()],
})
It adds no collections, fields or endpoints. It keeps its settings in config.custom, which Payload never sends to the admin panel, and warns at start-up when there is no key.
| Option | |
|---|---|
apiKey | Default process.env.SMSTUNNEL_API_KEY. |
deviceId | The phone that sends, when your account has several (its ID is under Phones, with a Copy button). Default process.env.SMSTUNNEL_DEVICE_ID, else your phone that is online. |
defaultCountryCode | Completes numbers written without + or 00, e.g. '+40'. It wins over the phone's own country. |
baseUrl | Default process.env.SMSTUNNEL_BASE_URL, else https://smstunnel.io. |
timeoutMs | Default 30000. |
enabled | false turns sending off, for example in development: the helpers then throw without calling SMSTunnel. Default true. |
src/collections/Orders.ts:
import type { CollectionConfig } from 'payload'
import { sendText } from '@narcisbodea/smstunnel-payload'
export const Orders: CollectionConfig = {
slug: 'orders',
fields: [
{ name: 'customerName', type: 'text' },
{ name: 'phone', type: 'text' },
],
hooks: {
afterChange: [
async ({ doc, operation, req }) => {
// Text the customer once, when the order is created, from your own phone.
if (operation !== 'create' || !doc.phone) return doc
try {
await sendText(req.payload, {
to: doc.phone,
message: `Thanks ${doc.customerName ?? ''}! We got your order #${doc.id}.`,
// The id and the creation time keep the key unique, so a retry can't send a second text.
idempotencyKey: `order-${doc.id}-${doc.createdAt}`,
})
} catch (error) {
// A text that can't go out must not fail the save: log it.
req.payload.logger.error(`SMSTunnel: ${(error as Error).message}`)
}
return doc
},
],
},
}
The hook waits for SMSTunnel's answer, usually well under a second. To keep saves from waiting at all, queue the text instead (below).
Ask for numbers in the international format (+14155550123), or set defaultCountryCode. Keep the phone field a text field: a number loses the + and leading zeros, and the plugin refuses a JavaScript number.
src/jobs/textCustomer.ts, registered with jobs: { tasks: [textCustomer] } in payload.config.ts:
import type { TaskConfig } from 'payload'
import { sendText } from '@narcisbodea/smstunnel-payload'
// A queued text: saves don't wait for SMSTunnel. A retry of the job reuses its key, so it can't text twice;
// the creation time keeps the key unique even if job ids start over (a new database).
export const textCustomer: TaskConfig<{ input: { to: string; message: string }; output: { messageId: string } }> = {
slug: 'textCustomer',
inputSchema: [
{ name: 'to', type: 'text', required: true },
{ name: 'message', type: 'text', required: true },
],
outputSchema: [{ name: 'messageId', type: 'text', required: true }],
retries: 2,
handler: async ({ input, job, req }) => {
const sent = await sendText(req.payload, { to: input.to, message: input.message, idempotencyKey: `job-${job.id}-${job.createdAt}` })
return { output: { messageId: sent.messageId } }
},
}
Then, from a hook or an endpoint: await req.payload.jobs.queue({ task: 'textCustomer', input: { to: doc.phone, message: '…' } }). Jobs run when your app runs them (autoRun or a cron).
All of them take req.payload (or the result of getPayload()), send one text to one number, and return { messageId, queued, replayed }:
sendText(payload, { to, message, deviceId?, defaultCountryCode?, idempotencyKey? }) | A text, up to 1600 characters. For several people, call it once per number. |
sendCode(payload, { to, message, ... }) | A sign-in or verification code. The text must contain the code: 4 to 10 digits on their own (482913, or 123-456), 320 characters at most. It counts against your sign-in code allowance. |
getSmsTunnel(payload) | The client, for getStatus(messageId), listPhones(), getUsage(). |
idempotencyKey: a second call with the same key within 24 hours gets the first answer back (replayed: true) instead of a second text. Use one key per text.
The helpers throw an SmsTunnelError with status, code, retryAfter and mayHaveSent:
| SMSTunnel answered | What it means |
|---|---|
| 401 | The API key is wrong, deactivated or deleted. Create a new one under Apps → Add an app. |
| 403 | The key lacks a permission (code: 'PERMISSION_REQUIRED', with permission), or your plan doesn't include what was asked. |
| 429 | Too many requests (30 sends a minute per key): retryAfter says how many seconds to wait. Without it, today's allowance of your plan is used up (pricing). |
| 5xx, or no answer | SMSTunnel had a problem. mayHaveSent is true: check the Messages page in your dashboard before you send it again, or send it again with the same idempotencyKey. |
| 400 | SMSTunnel refused a field, such as a number it can't read or a code text without a code. |
| 422 | The idempotency key was already used for a different text in the last 24 hours. |
A number that isn't one, several numbers in to, an empty text or one over 1600 characters is refused before anything is sent (kind: 'input'), and so is a call without a key or without the plugin.
If your phone is offline, the text isn't lost: queued is true, it waits in the queue on your account and goes out as soon as the phone is back online (up to 3 days).
The helpers never resend a text by themselves.
Paste this into Claude, ChatGPT, Cursor or Copilot and replace the part in brackets. Never paste your real API key into a prompt.
Help me send texts from my Payload CMS 3 app with SMSTunnel. SMSTunnel sends each text from my own Android phone, from my own number: the phone runs the SMSTunnel app and is linked to my SMSTunnel account.
I installed @narcisbodea/smstunnel-payload (npm install @narcisbodea/smstunnel-payload) and added smsTunnelPlugin() to plugins in payload.config.ts (options: apiKey, default process.env.SMSTUNNEL_API_KEY; deviceId, which phone sends; defaultCountryCode, e.g. "+40"; enabled). Server-side helpers, from '@narcisbodea/smstunnel-payload':
- sendText(req.payload, { to, message, deviceId?, defaultCountryCode?, idempotencyKey? }) → { messageId, queued, replayed }: one text to one number, up to 1600 characters;
- sendCode(req.payload, { to, message }) for sign-in codes: the text must contain a code of 4 to 10 digits standing on its own (e.g. 482913 or 123-456), at most 320 characters;
- getSmsTunnel(req.payload) → client with getStatus(messageId), listPhones(), getUsage().
They throw SmsTunnelError with status, code, retryAfter and mayHaveSent. Use them in collection hooks (afterChange with operation === 'create'), custom endpoints, or a Jobs Queue task (pass idempotencyKey: `job-${job.id}-${job.createdAt}` so retries can't text twice).
Behind it is the SMSTunnel API: POST https://smstunnel.io/api/v1/sms/send with the header X-API-Key and the JSON body {"to", "message", "deviceId"?, "defaultCountryCode"?}; one recipient per call (loop for several people); 30 send requests a minute per key; defaultCountryCode completes numbers written without + or 00. Errors: 401 wrong key, 403 missing permission or plan (code such as PERMISSION_REQUIRED), 429 too many requests (Retry-After) or today's allowance used up, 5xx SMSTunnel problem (the text may have gone out: never resend without the same idempotencyKey). If the phone is offline, the text waits in the queue (queued: true) and goes out when the phone is back online.
What I want: [describe what should send a text, to whom, and when]
Rules:
- Keep SMSTUNNEL_API_KEY in .env or the host's secret store, never in source code, the admin panel or client components; call the helpers only on the server.
- Store phone numbers as text fields in international format; validate them and skip the text when there is none.
- Handle errors: catch and log them; a failed text must not fail the save.
- Pass an idempotencyKey per text so retries can't text twice.
- Only send texts people expect (order updates, reminders, confirmations, sign-in codes).
Send only texts that people expect from you: order updates, reminders, confirmations, sign-in codes. Unsolicited messages from a personal SIM break most carriers' terms of service. Make sure your use follows your carrier's terms and local rules (in the EU, GDPR and the ePrivacy rules on electronic communications).
npm install
npm run typecheck # the plugin, and the examples in e2e/app against Payload's own types
npm test # unit tests, with fetch replaced (node --test)
npm run build # dist/ (ESM)
The end-to-end tests run only against a local SMSTunnel API, never smstunnel.io. They read { "serverUrl", "dockerServerUrl", "deviceId", "apiKey" | "keys" } from a JSON file and, with SMSTUNNEL_E2E_MONGO_URL, check each text in the test server's database:
export SMSTUNNEL_E2E_KEY_FILE=/path/to/test-key.json # SMSTUNNEL_E2E_KEY_NAME picks keys.<name>
npm run test:local-api # the client against the local API: send, status, phones, usage, idempotency
npm run test:e2e # Docker: Payload 3 (Local API, SQLite) with the packed plugin: the hook, the helpers, a queued job
npm run test:e2e uses the compose project smst-r3-payload and removes its containers and volumes at the end (--keep leaves them).
Links: SMSTunnel docs · Dashboard: Apps · Payload hooks · Payload Jobs Queue
Report a bug or ask for a feature at https://github.com/narcisbodea/smstunnel-payload/issues. For your SMSTunnel account, see https://smstunnel.io/docs/.
MIT, © NARBOWEB SRL. See LICENSE.
telegram
Send Telegram messages when Payload form builder forms are submitted, with optional UTM data
76499/wk0v4
payload plugin sms
Send SMS from Payload through Twilio, Telnyx, Plivo, Vonage or AWS SNS using a single sendSMS call
5380/wk7v3
email queue
Queue Payload form builder emails as background jobs so submissions return immediately and failed sends are retried
78466/wk0v4
payload plugin notifications
In-site notices with per-kind email copies, user preferences and a retrying send queue
74127/wk0v3
plugin emails
Transactional emails defined in code, with copy editors can change, preview and test-send from the admin.
7029/wk10v3
payload
Push publish, update and delete events from Payload to Hibira and refresh Next.js pages automatically
6814/wk0v3