[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"marketplace-site-banners":3,"github-stars":9,"@narcisbodea\u002Fsmstunnel-directus":115},[4],{"id":5,"icon":6,"content":7,"link":8,"include_paths":6,"exclude_paths":6},"5cf2f5f6-aecf-4395-8c23-69de326fdf02",null,"AI Assistant: Query Your Data, Update Content + More","https:\u002F\u002Fdirectus.com\u002Fai",{"id":10,"node_id":11,"name":12,"full_name":13,"private":14,"owner":15,"html_url":33,"description":34,"fork":14,"url":35,"forks_url":36,"keys_url":37,"collaborators_url":38,"teams_url":39,"hooks_url":40,"issue_events_url":41,"events_url":42,"assignees_url":43,"branches_url":44,"tags_url":45,"blobs_url":46,"git_tags_url":47,"git_refs_url":48,"trees_url":49,"statuses_url":50,"languages_url":51,"stargazers_url":52,"contributors_url":53,"subscribers_url":54,"subscription_url":55,"commits_url":56,"git_commits_url":57,"comments_url":58,"issue_comment_url":59,"contents_url":60,"compare_url":61,"merges_url":62,"archive_url":63,"downloads_url":64,"issues_url":65,"pulls_url":66,"milestones_url":67,"notifications_url":68,"labels_url":69,"releases_url":70,"deployments_url":71,"created_at":72,"updated_at":73,"pushed_at":74,"git_url":75,"ssh_url":76,"clone_url":77,"svn_url":33,"homepage":78,"size":79,"stargazers_count":80,"watchers_count":80,"language":81,"has_issues":82,"has_projects":82,"has_downloads":14,"has_wiki":14,"has_pages":14,"has_discussions":82,"forks_count":83,"mirror_url":6,"archived":14,"disabled":14,"open_issues_count":84,"license":85,"allow_forking":82,"is_template":14,"web_commit_signoff_required":14,"has_pull_requests":82,"pull_request_creation_policy":90,"topics":91,"visibility":32,"forks":83,"open_issues":84,"watchers":80,"default_branch":111,"temp_clone_token":6,"custom_properties":112,"organization":113,"network_count":83,"subscribers_count":114},7122594,"MDEwOlJlcG9zaXRvcnk3MTIyNTk0","directus","directus\u002Fdirectus",false,{"login":12,"id":16,"node_id":17,"avatar_url":18,"gravatar_id":19,"url":20,"html_url":21,"followers_url":22,"following_url":23,"gists_url":24,"starred_url":25,"subscriptions_url":26,"organizations_url":27,"repos_url":28,"events_url":29,"received_events_url":30,"type":31,"user_view_type":32,"site_admin":14},15967950,"MDEyOk9yZ2FuaXphdGlvbjE1OTY3OTUw","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F15967950?v=4","","https:\u002F\u002Fapi.github.com\u002Fusers\u002Fdirectus","https:\u002F\u002Fgithub.com\u002Fdirectus","https:\u002F\u002Fapi.github.com\u002Fusers\u002Fdirectus\u002Ffollowers","https:\u002F\u002Fapi.github.com\u002Fusers\u002Fdirectus\u002Ffollowing{\u002Fother_user}","https:\u002F\u002Fapi.github.com\u002Fusers\u002Fdirectus\u002Fgists{\u002Fgist_id}","https:\u002F\u002Fapi.github.com\u002Fusers\u002Fdirectus\u002Fstarred{\u002Fowner}{\u002Frepo}","https:\u002F\u002Fapi.github.com\u002Fusers\u002Fdirectus\u002Fsubscriptions","https:\u002F\u002Fapi.github.com\u002Fusers\u002Fdirectus\u002Forgs","https:\u002F\u002Fapi.github.com\u002Fusers\u002Fdirectus\u002Frepos","https:\u002F\u002Fapi.github.com\u002Fusers\u002Fdirectus\u002Fevents{\u002Fprivacy}","https:\u002F\u002Fapi.github.com\u002Fusers\u002Fdirectus\u002Freceived_events","Organization","public","https:\u002F\u002Fgithub.com\u002Fdirectus\u002Fdirectus","The flexible backend for all your projects 🐰 Turn your DB into a headless CMS, admin panels, or apps with a custom UI, instant APIs, auth & more.","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fforks","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fkeys{\u002Fkey_id}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fcollaborators{\u002Fcollaborator}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fteams","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fhooks","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fissues\u002Fevents{\u002Fnumber}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fevents","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fassignees{\u002Fuser}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fbranches{\u002Fbranch}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Ftags","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fgit\u002Fblobs{\u002Fsha}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fgit\u002Ftags{\u002Fsha}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fgit\u002Frefs{\u002Fsha}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fgit\u002Ftrees{\u002Fsha}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fstatuses\u002F{sha}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Flanguages","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fstargazers","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fcontributors","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fsubscribers","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fsubscription","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fcommits{\u002Fsha}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fgit\u002Fcommits{\u002Fsha}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fcomments{\u002Fnumber}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fissues\u002Fcomments{\u002Fnumber}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fcontents\u002F{+path}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fcompare\u002F{base}...{head}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fmerges","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002F{archive_format}{\u002Fref}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fdownloads","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fissues{\u002Fnumber}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fpulls{\u002Fnumber}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fmilestones{\u002Fnumber}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fnotifications{?since,all,participating}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Flabels{\u002Fname}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Freleases{\u002Fid}","https:\u002F\u002Fapi.github.com\u002Frepos\u002Fdirectus\u002Fdirectus\u002Fdeployments","2012-12-12T01:35:36Z","2026-11-20T20:30:50Z","2026-11-20T21:22:49Z","git:\u002F\u002Fgithub.com\u002Fdirectus\u002Fdirectus.git","git@github.com:directus\u002Fdirectus.git","https:\u002F\u002Fgithub.com\u002Fdirectus\u002Fdirectus.git","https:\u002F\u002Fdirectus.com",454768,38609,"TypeScript",true,4997,344,{"key":86,"name":87,"spdx_id":88,"url":6,"node_id":89},"other","Other","NOASSERTION","MDc6TGljZW5zZTA=","all",[92,93,94,95,96,97,12,98,99,100,101,102,103,104,105,106,107,108,109,110],"api","app","cms","composable","data-visualization","database","graphql","headless-cms","javascript","mariadb","mssql","mysql","no-code","node","postgresql","sql","sqlite","typescript","vue","main",{},{"login":12,"id":16,"node_id":17,"avatar_url":18,"gravatar_id":19,"url":20,"html_url":21,"followers_url":22,"following_url":23,"gists_url":24,"starred_url":25,"subscriptions_url":26,"organizations_url":27,"repos_url":28,"events_url":29,"received_events_url":30,"type":31,"user_view_type":32,"site_admin":14},341,{"name":116,"description":117,"verified":14,"id":118,"readme":119,"type":120,"publisher":121,"last_updated":126,"host_version":127,"downloads":128,"total_downloads":129,"sandbox":82,"license":130,"versions":131,"formatted_name":151,"formatted_readme":152,"formatted_description":117,"featured_image":153,"images":154,"repository_url":135,"recent_downloads_7_days":129,"recent_downloads_30_days":129},"@narcisbodea\u002Fsmstunnel-directus","SMSTunnel for Directus: a \"Send a text with SMSTunnel\" operation for Flows. Texts go out from your own Android phone, from your own number.","af28a641-9cf7-4819-9690-c63161c777a7","# SMSTunnel for Directus\n\n`@narcisbodea\u002Fsmstunnel-directus`: a **Send a text with SMSTunnel** operation for Directus Flows. Each run sends one text from **your own Android phone**, from **your own number**, through [SMSTunnel](https:\u002F\u002Fsmstunnel.io).\n\nA flow hands the 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.\n\n\u003Ca href=\"https:\u002F\u002Fplay.google.com\u002Fstore\u002Fapps\u002Fdetails?id=io.smstunnel.app\">\u003Cimg src=\"https:\u002F\u002Fsmstunnel.io\u002Fgoogle-play-badge.png\" alt=\"Get it on Google Play\" height=\"56\">\u003C\u002Fa>\n\nSMSTunnel for Directus is made by NARBOWEB SRL. It is not affiliated with, endorsed by, or sponsored by Monospace Inc. or the Directus project.\n\n## Install\n\n**From the Marketplace** (Directus 11 and 12): **Settings → Marketplace**, search for **SMSTunnel**, open it and click **Install**. The operation runs in Directus' extension sandbox, so the Marketplace installs it with its default trust setting (`MARKETPLACE_TRUST=sandbox`). The sandbox lets it call only `https:\u002F\u002Fsmstunnel.io\u002Fapi\u002Fv1\u002F*`.\n\n**By hand** (self-hosted): put the package in your extensions folder and restart Directus:\n\n```bash\ncd extensions\nnpm pack @narcisbodea\u002Fsmstunnel-directus\nmkdir smstunnel-directus && tar -xzf narcisbodea-smstunnel-directus-*.tgz -C smstunnel-directus --strip-components=1\n```\n\nTested with Directus 12.6.0 and 11.17.4.\n\n## Get your key\n\n1. Install the [SMSTunnel app from Google Play](https:\u002F\u002Fplay.google.com\u002Fstore\u002Fapps\u002Fdetails?id=io.smstunnel.app) on the Android phone that will send the texts, and sign in.\n2. Open your dashboard at [dashboard.smstunnel.io\u002Fapps](https:\u002F\u002Fdashboard.smstunnel.io\u002Fapps). The phone shows up under **Phones** (or link it there with **Phones → Add phone**).\n3. Under **Apps**, click **Add an app** and copy the key it shows. A new key can send texts and look up their status.\n\nThen give it to Directus as an environment variable, and let flows read it:\n\n```bash\nSMSTUNNEL_API_KEY=sk_live_...\nFLOWS_ENV_ALLOW_LIST=SMSTUNNEL_API_KEY\n```\n\nRestart Directus. The operation's **API key** field is already `{{ $env.SMSTUNNEL_API_KEY }}`: the key stays out of your flows, and Directus shows it as `--redacted:SMSTUNNEL_API_KEY--` in the flow logs. (Pasting the key into the field works too, but then it is stored with the flow and appears in its logs; keep that for a quick test.)\n\n## Text each new item\n\nFor example a `leads` collection with `name` and `phone` fields:\n\n1. **Settings → Flows → Create Flow**. Name it, choose the trigger **Event Hook**, type **Action (Non-Blocking)**, scope `items.create`, collection **leads**.\n2. Click **+** after the trigger and choose **Send a text with SMSTunnel**:\n   - **To**: `{{ $trigger.payload.phone }}`\n   - **Message**: `Thanks {{ $trigger.payload.name }}, we got your request and will call you back today.`\n   - **Idempotency key**: `lead-{{ $trigger.key }}`\n3. Save, then add a lead with your own number.\n\nThe same operation fits after a **Webhook**, a **Schedule (CRON)**, a **Manual** trigger or another operation: every field takes `{{ … }}`.\n\n| Field | |\n| --- | --- |\n| **API key** | `{{ $env.SMSTUNNEL_API_KEY }}` (see above). |\n| **To** | One number, in international format (`+14155550123`). |\n| **Type** | **Text**, or **Sign-in code**: the text must then contain the code, 4 to 10 digits on their own (`482913`, or `123-456`), 320 characters at most, and it counts against your sign-in code allowance. |\n| **Message** | Up to 1600 characters. |\n| **Phone ID** | Optional: the phone that sends, when your account has several (its ID is under **Phones**, with a Copy button). Empty: your phone that is online. |\n| **Country code** | Optional, e.g. `+40`: completes numbers written without `+` or `00`. |\n| **Idempotency key** | Optional: one key per text. Running it again with the same key within 24 hours sends nothing new (the run reports `replayed: true`). Make it unique for good: a key used for another text in the last 24 hours is refused. |\n\nA `{{ … }}` that finds nothing (Directus then writes `undefined`) counts as empty for the optional fields, and as missing for **To** and **Message**.\n\n## What the next operations get\n\nWhen the text is handed over, the operation resolves with:\n\n```json\n{ \"messageId\": \"6ae9952f7f9ac207c547af90\", \"to\": \"+14155550123\", \"status\": \"pending\", \"queued\": false, \"replayed\": false }\n```\n\n`status` is `queued` when your phone is offline: the text waits in the queue on your account and goes out as soon as the phone is back online (up to 3 days). Read it later as `{{ $last.messageId }}` or `{{ \u003Coperation key>.messageId }}`.\n\nWhen it isn't, the flow takes the operation's **reject** path, with:\n\n```json\n{ \"message\": \"SMSTunnel refused the API key: …\", \"status\": 401, \"mayHaveSent\": false }\n```\n\n| `status` | What it means |\n| --- | --- |\n| 401 | The API key is wrong, deactivated or deleted. Create a new one under **Apps → Add an app**. |\n| 403 | The key lacks a permission, or your plan doesn't include what was asked. |\n| 429 | Too many requests (30 sends a minute per key), or today's allowance of your plan is used up ([pricing](https:\u002F\u002Fsmstunnel.io\u002Fpricing\u002F)). |\n| 5xx, or none | SMSTunnel had a problem or didn't answer. `mayHaveSent` is `true`: check the Messages page in your dashboard before you send it again, or run it again with the same idempotency key. |\n| 400 | SMSTunnel refused a field, such as a number it can't read or a code text without a code. |\n| 404 | The phone ID isn't one of your phones. |\n| 422 | The idempotency key was already used for a different text in the last 24 hours. |\n\nA number that isn't one, a list of numbers, an empty text or one over 1600 characters is refused before anything is sent (no `status`). Inside Directus' sandbox only SMSTunnel's status code reaches the extension, so the reasons above are worded from the status.\n\nThe operation never resends a text by itself.\n\n## Several people\n\nOne run sends one text. To text a list, put the operation in its own flow (trigger **Another Flow**, To `{{ $trigger.phone }}`), and call that flow from a **Trigger Flow** operation whose payload is the list, for example `{{ $last }}` from a **Read Data** operation. Directus runs the flow once per item; choose **Serial** as the iteration mode to keep within 30 texts a minute.\n\n## Build it with an AI assistant\n\nPaste this into Claude, ChatGPT, Cursor or Copilot and replace the part in brackets. Never paste your real API key into a prompt.\n\n```text\nHelp me send texts from Directus 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.\n\nI installed the Directus extension @narcisbodea\u002Fsmstunnel-directus (Marketplace: \"SMSTunnel\"). It adds the Flows operation \"Send a text with SMSTunnel\" (type id smstunnel-send-text) with the options: apiKey (keep \"{{ $env.SMSTUNNEL_API_KEY }}\"; Directus has SMSTUNNEL_API_KEY and FLOWS_ENV_ALLOW_LIST=SMSTUNNEL_API_KEY in its environment), to (one number in international format, e.g. \"{{ $trigger.payload.phone }}\"), kind (\"text\" or \"code\"; a code text must contain a code of 4 to 10 digits standing on its own, at most 320 characters), message (up to 1600 characters), deviceId (optional: which phone sends), defaultCountryCode (optional, e.g. \"+40\", completes numbers written without + or 00), idempotencyKey (optional, one per text: a re-run with the same key within 24 h sends nothing new). It resolves with { messageId, to, status: \"pending\" | \"queued\", queued, replayed } and rejects with { message, status, code?, retryAfter?, mayHaveSent }. One text per run: for a list, a Trigger Flow operation (iteration mode Serial) calls a flow that holds this operation once per item.\n\nBehind it is the SMSTunnel API: POST https:\u002F\u002Fsmstunnel.io\u002Fapi\u002Fv1\u002Fsms\u002Fsend with the header X-API-Key and the JSON body {\"to\", \"message\", \"deviceId\"?, \"defaultCountryCode\"?}; one recipient per call; 30 send requests a minute per key. Errors: 401 wrong key, 403 missing permission or plan, 429 too many requests or today's allowance used up, 5xx SMSTunnel problem (the text may have gone out: never resend without the same idempotency key). If the phone is offline, the text waits in the queue (status \"queued\") and goes out when the phone is back online.\n\nWhat I want: [describe what should send a text, to whom, and when]\n\nGive me the flow step by step (trigger, its options, each operation and its options), plus the collection fields it needs.\n\nRules:\n- Keep the key in Directus' environment through {{ $env.SMSTUNNEL_API_KEY }}, never pasted into a flow, a script operation or anything a browser can see.\n- Store phone numbers as text in international format; skip the text (a Condition operation) when there is none.\n- Handle the reject path: log it or notify an admin; don't loop back into the same operation.\n- Only send texts people expect (confirmations, reminders, order updates, sign-in codes).\n```\n\n## Responsible use\n\nSend only texts that people expect from you: confirmations, reminders, order updates, 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).\n\n## Development\n\n```bash\nnpm install\nnpm run typecheck\nnpm test            # unit tests: the operation with a fake sandbox request, the client with fetch replaced\nnpm run build       # directus-extension build → dist\u002Fapi.js (sandboxed) and dist\u002Fapp.js\n```\n\nThe 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:\n\n```bash\nexport SMSTUNNEL_E2E_KEY_FILE=\u002Fpath\u002Fto\u002Ftest-key.json   # SMSTUNNEL_E2E_KEY_NAME picks keys.\u003Cname>\nnpm run test:local-api              # the client against the local API\nnpm run test:e2e                    # Docker: directus\u002Fdirectus:12.6.0 with the built extension, flows made through the REST API\nDIRECTUS_VERSION=11.17.4 npm run test:e2e\n```\n\nIn the copy the end-to-end test mounts, the sandbox may call only the local API (not even smstunnel.io). It uses the compose project `smst-r3-directus` and removes its container and volumes at the end (`--keep` leaves it running).\n\nLinks: [SMSTunnel docs](https:\u002F\u002Fsmstunnel.io\u002Fdocs\u002F) · [Dashboard: Apps](https:\u002F\u002Fdashboard.smstunnel.io\u002Fapps) · [Directus Flows](https:\u002F\u002Fdirectus.com\u002Fdocs\u002Fguides\u002Fautomate\u002Fflows)\n\n## Issues\n\nReport a bug or ask for a feature at \u003Chttps:\u002F\u002Fgithub.com\u002Fnarcisbodea\u002Fsmstunnel-directus\u002Fissues>. For your SMSTunnel account, see \u003Chttps:\u002F\u002Fsmstunnel.io\u002Fdocs\u002F>.\n\n## License\n\nMIT, © NARBOWEB SRL. See [LICENSE](LICENSE).\n","operation",{"username":122,"verified":14,"id":123,"github_username":122,"github_name":124,"github_blog":19,"github_bio":6,"github_location":6,"github_company":6,"github_avatar_url":125},"narcisbodea","98cba7c4-dead-4178-a840-1c7eec321062","Narcis Bodea","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6988177?v=4","2026-11-19T15:47:39.994Z","^11.0.0 || ^12.0.0",[],0,"MIT",[132],{"version":133,"package":118,"publisher":123,"type":120,"host_version":127,"publish_date":126,"verified":14,"id":134,"url_repository":135,"url_homepage":136,"url_bugs":137,"file_count":138,"unpacked_size":139,"bundled":140,"maintainers":141,"sandbox":82,"sandbox_requested_scopes":143,"license":130},"1.0.0","1d84e8ea-f897-40fb-8396-9d87cb3a82d3","https:\u002F\u002Fgithub.com\u002Fnarcisbodea\u002Fsmstunnel-directus.git","https:\u002F\u002Fgithub.com\u002Fnarcisbodea\u002Fsmstunnel-directus#readme","https:\u002F\u002Fgithub.com\u002Fnarcisbodea\u002Fsmstunnel-directus\u002Fissues",6,29325,[],[142],15339,{"request":144,"log":150},{"urls":145,"methods":147},[146],"https:\u002F\u002Fsmstunnel.io\u002Fapi\u002Fv1\u002F*",[148,149],"GET","POST",{},"Smstunnel Directus","\u003Ch1>SMSTunnel for Directus\u003C\u002Fh1>\n\u003Cp>\u003Ccode>@narcisbodea\u002Fsmstunnel-directus\u003C\u002Fcode>: a \u003Cstrong>Send a text with SMSTunnel\u003C\u002Fstrong> operation for Directus Flows. Each run sends one text from \u003Cstrong>your own Android phone\u003C\u002Fstrong>, from \u003Cstrong>your own number\u003C\u002Fstrong>, through \u003Ca href=\"https:\u002F\u002Fsmstunnel.io\">SMSTunnel\u003C\u002Fa>.\u003C\u002Fp>\n\u003Cp>A flow hands the 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.\u003C\u002Fp>\n\u003Cp>\u003Ca href=\"https:\u002F\u002Fplay.google.com\u002Fstore\u002Fapps\u002Fdetails?id=io.smstunnel.app\">\u003Cimg src=\"https:\u002F\u002Fsmstunnel.io\u002Fgoogle-play-badge.png\" alt=\"Get it on Google Play\">\u003C\u002Fa>\u003C\u002Fp>\n\u003Cp>SMSTunnel for Directus is made by NARBOWEB SRL. It is not affiliated with, endorsed by, or sponsored by Monospace Inc. or the Directus project.\u003C\u002Fp>\n\u003Ch2>Install\u003C\u002Fh2>\n\u003Cp>\u003Cstrong>From the Marketplace\u003C\u002Fstrong> (Directus 11 and 12): \u003Cstrong>Settings → Marketplace\u003C\u002Fstrong>, search for \u003Cstrong>SMSTunnel\u003C\u002Fstrong>, open it and click \u003Cstrong>Install\u003C\u002Fstrong>. The operation runs in Directus' extension sandbox, so the Marketplace installs it with its default trust setting (\u003Ccode>MARKETPLACE_TRUST=sandbox\u003C\u002Fcode>). The sandbox lets it call only \u003Ccode>https:\u002F\u002Fsmstunnel.io\u002Fapi\u002Fv1\u002F*\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Cp>\u003Cstrong>By hand\u003C\u002Fstrong> (self-hosted): put the package in your extensions folder and restart Directus:\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-bash\">cd extensions\nnpm pack @narcisbodea\u002Fsmstunnel-directus\nmkdir smstunnel-directus &amp;&amp; tar -xzf narcisbodea-smstunnel-directus-*.tgz -C smstunnel-directus --strip-components=1\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Tested with Directus 12.6.0 and 11.17.4.\u003C\u002Fp>\n\u003Ch2>Get your key\u003C\u002Fh2>\n\u003Col>\n\u003Cli>Install the \u003Ca href=\"https:\u002F\u002Fplay.google.com\u002Fstore\u002Fapps\u002Fdetails?id=io.smstunnel.app\">SMSTunnel app from Google Play\u003C\u002Fa> on the Android phone that will send the texts, and sign in.\u003C\u002Fli>\n\u003Cli>Open your dashboard at \u003Ca href=\"https:\u002F\u002Fdashboard.smstunnel.io\u002Fapps\">dashboard.smstunnel.io\u002Fapps\u003C\u002Fa>. The phone shows up under \u003Cstrong>Phones\u003C\u002Fstrong> (or link it there with \u003Cstrong>Phones → Add phone\u003C\u002Fstrong>).\u003C\u002Fli>\n\u003Cli>Under \u003Cstrong>Apps\u003C\u002Fstrong>, click \u003Cstrong>Add an app\u003C\u002Fstrong> and copy the key it shows. A new key can send texts and look up their status.\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Cp>Then give it to Directus as an environment variable, and let flows read it:\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-bash\">SMSTUNNEL_API_KEY=sk_live_...\nFLOWS_ENV_ALLOW_LIST=SMSTUNNEL_API_KEY\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>Restart Directus. The operation's \u003Cstrong>API key\u003C\u002Fstrong> field is already \u003Ccode>{{ $env.SMSTUNNEL_API_KEY }}\u003C\u002Fcode>: the key stays out of your flows, and Directus shows it as \u003Ccode>--redacted:SMSTUNNEL_API_KEY--\u003C\u002Fcode> in the flow logs. (Pasting the key into the field works too, but then it is stored with the flow and appears in its logs; keep that for a quick test.)\u003C\u002Fp>\n\u003Ch2>Text each new item\u003C\u002Fh2>\n\u003Cp>For example a \u003Ccode>leads\u003C\u002Fcode> collection with \u003Ccode>name\u003C\u002Fcode> and \u003Ccode>phone\u003C\u002Fcode> fields:\u003C\u002Fp>\n\u003Col>\n\u003Cli>\u003Cstrong>Settings → Flows → Create Flow\u003C\u002Fstrong>. Name it, choose the trigger \u003Cstrong>Event Hook\u003C\u002Fstrong>, type \u003Cstrong>Action (Non-Blocking)\u003C\u002Fstrong>, scope \u003Ccode>items.create\u003C\u002Fcode>, collection \u003Cstrong>leads\u003C\u002Fstrong>.\u003C\u002Fli>\n\u003Cli>Click \u003Cstrong>+\u003C\u002Fstrong> after the trigger and choose \u003Cstrong>Send a text with SMSTunnel\u003C\u002Fstrong>:\n\u003Cul>\n\u003Cli>\u003Cstrong>To\u003C\u002Fstrong>: \u003Ccode>{{ $trigger.payload.phone }}\u003C\u002Fcode>\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Message\u003C\u002Fstrong>: \u003Ccode>Thanks {{ $trigger.payload.name }}, we got your request and will call you back today.\u003C\u002Fcode>\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Idempotency key\u003C\u002Fstrong>: \u003Ccode>lead-{{ $trigger.key }}\u003C\u002Fcode>\u003C\u002Fli>\n\u003C\u002Ful>\n\u003C\u002Fli>\n\u003Cli>Save, then add a lead with your own number.\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Cp>The same operation fits after a \u003Cstrong>Webhook\u003C\u002Fstrong>, a \u003Cstrong>Schedule (CRON)\u003C\u002Fstrong>, a \u003Cstrong>Manual\u003C\u002Fstrong> trigger or another operation: every field takes \u003Ccode>{{ … }}\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Field\u003C\u002Fth>\n\u003Cth>\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>API key\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>\u003Ccode>{{ $env.SMSTUNNEL_API_KEY }}\u003C\u002Fcode> (see above).\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>To\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>One number, in international format (\u003Ccode>+14155550123\u003C\u002Fcode>).\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Type\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>\u003Cstrong>Text\u003C\u002Fstrong>, or \u003Cstrong>Sign-in code\u003C\u002Fstrong>: the text must then contain the code, 4 to 10 digits on their own (\u003Ccode>482913\u003C\u002Fcode>, or \u003Ccode>123-456\u003C\u002Fcode>), 320 characters at most, and it counts against your sign-in code allowance.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Message\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>Up to 1600 characters.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Phone ID\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>Optional: the phone that sends, when your account has several (its ID is under \u003Cstrong>Phones\u003C\u002Fstrong>, with a Copy button). Empty: your phone that is online.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Country code\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>Optional, e.g. \u003Ccode>+40\u003C\u002Fcode>: completes numbers written without \u003Ccode>+\u003C\u002Fcode> or \u003Ccode>00\u003C\u002Fcode>.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Cstrong>Idempotency key\u003C\u002Fstrong>\u003C\u002Ftd>\n\u003Ctd>Optional: one key per text. Running it again with the same key within 24 hours sends nothing new (the run reports \u003Ccode>replayed: true\u003C\u002Fcode>). Make it unique for good: a key used for another text in the last 24 hours is refused.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Cp>A \u003Ccode>{{ … }}\u003C\u002Fcode> that finds nothing (Directus then writes \u003Ccode>undefined\u003C\u002Fcode>) counts as empty for the optional fields, and as missing for \u003Cstrong>To\u003C\u002Fstrong> and \u003Cstrong>Message\u003C\u002Fstrong>.\u003C\u002Fp>\n\u003Ch2>What the next operations get\u003C\u002Fh2>\n\u003Cp>When the text is handed over, the operation resolves with:\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-json\">{ \"messageId\": \"6ae9952f7f9ac207c547af90\", \"to\": \"+14155550123\", \"status\": \"pending\", \"queued\": false, \"replayed\": false }\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>\u003Ccode>status\u003C\u002Fcode> is \u003Ccode>queued\u003C\u002Fcode> when your phone is offline: the text waits in the queue on your account and goes out as soon as the phone is back online (up to 3 days). Read it later as \u003Ccode>{{ $last.messageId }}\u003C\u002Fcode> or \u003Ccode>{{ &lt;operation key&gt;.messageId }}\u003C\u002Fcode>.\u003C\u002Fp>\n\u003Cp>When it isn't, the flow takes the operation's \u003Cstrong>reject\u003C\u002Fstrong> path, with:\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-json\">{ \"message\": \"SMSTunnel refused the API key: …\", \"status\": 401, \"mayHaveSent\": false }\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>\u003Ccode>status\u003C\u002Fcode>\u003C\u002Fth>\n\u003Cth>What it means\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>401\u003C\u002Ftd>\n\u003Ctd>The API key is wrong, deactivated or deleted. Create a new one under \u003Cstrong>Apps → Add an app\u003C\u002Fstrong>.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>403\u003C\u002Ftd>\n\u003Ctd>The key lacks a permission, or your plan doesn't include what was asked.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>429\u003C\u002Ftd>\n\u003Ctd>Too many requests (30 sends a minute per key), or today's allowance of your plan is used up (\u003Ca href=\"https:\u002F\u002Fsmstunnel.io\u002Fpricing\u002F\">pricing\u003C\u002Fa>).\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>5xx, or none\u003C\u002Ftd>\n\u003Ctd>SMSTunnel had a problem or didn't answer. \u003Ccode>mayHaveSent\u003C\u002Fcode> is \u003Ccode>true\u003C\u002Fcode>: check the Messages page in your dashboard before you send it again, or run it again with the same idempotency key.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>400\u003C\u002Ftd>\n\u003Ctd>SMSTunnel refused a field, such as a number it can't read or a code text without a code.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>404\u003C\u002Ftd>\n\u003Ctd>The phone ID isn't one of your phones.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>422\u003C\u002Ftd>\n\u003Ctd>The idempotency key was already used for a different text in the last 24 hours.\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Cp>A number that isn't one, a list of numbers, an empty text or one over 1600 characters is refused before anything is sent (no \u003Ccode>status\u003C\u002Fcode>). Inside Directus' sandbox only SMSTunnel's status code reaches the extension, so the reasons above are worded from the status.\u003C\u002Fp>\n\u003Cp>The operation never resends a text by itself.\u003C\u002Fp>\n\u003Ch2>Several people\u003C\u002Fh2>\n\u003Cp>One run sends one text. To text a list, put the operation in its own flow (trigger \u003Cstrong>Another Flow\u003C\u002Fstrong>, To \u003Ccode>{{ $trigger.phone }}\u003C\u002Fcode>), and call that flow from a \u003Cstrong>Trigger Flow\u003C\u002Fstrong> operation whose payload is the list, for example \u003Ccode>{{ $last }}\u003C\u002Fcode> from a \u003Cstrong>Read Data\u003C\u002Fstrong> operation. Directus runs the flow once per item; choose \u003Cstrong>Serial\u003C\u002Fstrong> as the iteration mode to keep within 30 texts a minute.\u003C\u002Fp>\n\u003Ch2>Build it with an AI assistant\u003C\u002Fh2>\n\u003Cp>Paste this into Claude, ChatGPT, Cursor or Copilot and replace the part in brackets. Never paste your real API key into a prompt.\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-text\">Help me send texts from Directus 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.\n\nI installed the Directus extension @narcisbodea\u002Fsmstunnel-directus (Marketplace: \"SMSTunnel\"). It adds the Flows operation \"Send a text with SMSTunnel\" (type id smstunnel-send-text) with the options: apiKey (keep \"{{ $env.SMSTUNNEL_API_KEY }}\"; Directus has SMSTUNNEL_API_KEY and FLOWS_ENV_ALLOW_LIST=SMSTUNNEL_API_KEY in its environment), to (one number in international format, e.g. \"{{ $trigger.payload.phone }}\"), kind (\"text\" or \"code\"; a code text must contain a code of 4 to 10 digits standing on its own, at most 320 characters), message (up to 1600 characters), deviceId (optional: which phone sends), defaultCountryCode (optional, e.g. \"+40\", completes numbers written without + or 00), idempotencyKey (optional, one per text: a re-run with the same key within 24 h sends nothing new). It resolves with { messageId, to, status: \"pending\" | \"queued\", queued, replayed } and rejects with { message, status, code?, retryAfter?, mayHaveSent }. One text per run: for a list, a Trigger Flow operation (iteration mode Serial) calls a flow that holds this operation once per item.\n\nBehind it is the SMSTunnel API: POST https:\u002F\u002Fsmstunnel.io\u002Fapi\u002Fv1\u002Fsms\u002Fsend with the header X-API-Key and the JSON body {\"to\", \"message\", \"deviceId\"?, \"defaultCountryCode\"?}; one recipient per call; 30 send requests a minute per key. Errors: 401 wrong key, 403 missing permission or plan, 429 too many requests or today's allowance used up, 5xx SMSTunnel problem (the text may have gone out: never resend without the same idempotency key). If the phone is offline, the text waits in the queue (status \"queued\") and goes out when the phone is back online.\n\nWhat I want: [describe what should send a text, to whom, and when]\n\nGive me the flow step by step (trigger, its options, each operation and its options), plus the collection fields it needs.\n\nRules:\n- Keep the key in Directus' environment through {{ $env.SMSTUNNEL_API_KEY }}, never pasted into a flow, a script operation or anything a browser can see.\n- Store phone numbers as text in international format; skip the text (a Condition operation) when there is none.\n- Handle the reject path: log it or notify an admin; don't loop back into the same operation.\n- Only send texts people expect (confirmations, reminders, order updates, sign-in codes).\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2>Responsible use\u003C\u002Fh2>\n\u003Cp>Send only texts that people expect from you: confirmations, reminders, order updates, 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).\u003C\u002Fp>\n\u003Ch2>Development\u003C\u002Fh2>\n\u003Cpre>\u003Ccode class=\"language-bash\">npm install\nnpm run typecheck\nnpm test            # unit tests: the operation with a fake sandbox request, the client with fetch replaced\nnpm run build       # directus-extension build → dist\u002Fapi.js (sandboxed) and dist\u002Fapp.js\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>The end-to-end tests run only against a local SMSTunnel API, never smstunnel.io. They read \u003Ccode>{ \"serverUrl\", \"dockerServerUrl\", \"deviceId\", \"apiKey\" | \"keys\" }\u003C\u002Fcode> from a JSON file and, with \u003Ccode>SMSTUNNEL_E2E_MONGO_URL\u003C\u002Fcode>, check each text in the test server's database:\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-bash\">export SMSTUNNEL_E2E_KEY_FILE=\u002Fpath\u002Fto\u002Ftest-key.json   # SMSTUNNEL_E2E_KEY_NAME picks keys.&lt;name&gt;\nnpm run test:local-api              # the client against the local API\nnpm run test:e2e                    # Docker: directus\u002Fdirectus:12.6.0 with the built extension, flows made through the REST API\nDIRECTUS_VERSION=11.17.4 npm run test:e2e\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>In the copy the end-to-end test mounts, the sandbox may call only the local API (not even smstunnel.io). It uses the compose project \u003Ccode>smst-r3-directus\u003C\u002Fcode> and removes its container and volumes at the end (\u003Ccode>--keep\u003C\u002Fcode> leaves it running).\u003C\u002Fp>\n\u003Cp>Links: \u003Ca href=\"https:\u002F\u002Fsmstunnel.io\u002Fdocs\u002F\">SMSTunnel docs\u003C\u002Fa> · \u003Ca href=\"https:\u002F\u002Fdashboard.smstunnel.io\u002Fapps\">Dashboard: Apps\u003C\u002Fa> · \u003Ca href=\"https:\u002F\u002Fdirectus.com\u002Fdocs\u002Fguides\u002Fautomate\u002Fflows\">Directus Flows\u003C\u002Fa>\u003C\u002Fp>\n\u003Ch2>Issues\u003C\u002Fh2>\n\u003Cp>Report a bug or ask for a feature at \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fnarcisbodea\u002Fsmstunnel-directus\u002Fissues\">https:\u002F\u002Fgithub.com\u002Fnarcisbodea\u002Fsmstunnel-directus\u002Fissues\u003C\u002Fa>. For your SMSTunnel account, see \u003Ca href=\"https:\u002F\u002Fsmstunnel.io\u002Fdocs\u002F\">https:\u002F\u002Fsmstunnel.io\u002Fdocs\u002F\u003C\u002Fa>.\u003C\u002Fp>\n\u003Ch2>License\u003C\u002Fh2>\n\u003Cp>MIT, © NARBOWEB SRL. See \u003Ca href=\"LICENSE\">LICENSE\u003C\u002Fa>.\u003C\u002Fp>\n","https:\u002F\u002Fsmstunnel.io\u002Fgoogle-play-badge.png",[153]]