Twilio clone
Exercise SMS OTP, Verify check flows, voice/TwiML callbacks, and conversations in a stateful Twilio twin — magic test numbers, deterministic OTP lookup, and in-memory delivery (no PSTN).
Clone ID: twilio · Binary: clones-twilio · SDK: twilio · Dashboard: Twilio explorer
Start here
| Question | Answer |
|---|---|
| Best for | SMS OTP signup, Verify v2, status callbacks, voice gather flows, and conversation threads |
| Connect with | @molar/clones SDK, Twilio SDK with base URL override, route mode for api.twilio.com, REST at clone base URL, or MCP |
| Known limits | No real carrier delivery; recordings are stub artifacts unless you wire S3 hooks |
| Seeds | Empty by default; optional JSON seed for phone numbers (see below) |
Quick start
import { twilio } from "@molar/clones";
const clone = await twilio.start({ seed: "otp-signup", runId: "run-twilio-01" });
await clone.createMessage({ from: "+15005550006", to: "+14155550123", body: "Hi" });
const verification = await clone.createVerification("+14155550123", "sms");
const code = await clone.lastOTP("+14155550123");
await clone.checkVerification("+14155550123", code);
Advance the virtual clock to move queued messages to delivered.
MCP tools
| Tool | Description |
|---|---|
molar_clone_spawn | Spawn Twilio clone (kind: "twilio", optional seed) |
twilio_last_otp | Read deterministic OTP for a recipient (adminUrl, runId, to) |
molar_clone_advance_clock | Advance virtual time (scheduled message delivery) |
molar_clone_inject_error | Inject HTTP errors for rate-limit / 5xx chaos |
REST API coverage
Twilio-compatible REST under {base}/t/{runId}/...:
| API surface | Operations |
|---|---|
| Messages | Create SMS/MMS, list, fetch status, segment counting |
| Calls | Create, list, get, update; TwiML fetch for Say / Gather / Play / Hangup / Record |
| Incoming phone numbers | Provision and list numbers |
| Verify v2 | Create service, create verification, check code |
| Conversations | Create conversation, post and list messages |
Template-approved sends (template:... body); non-approved templates return 63016 | |
| Status callbacks | POST to your app URL (captured in admin delivery logs) |
Point the Twilio SDK at the clone with TWILIO_API_BASE or use route mode — see API & SDK.
Magic numbers
Twilio test magic numbers are built in:
| Number | Behavior |
|---|---|
+15005550001 | Invalid To |
+15005550002 | Can't route |
+15005550003 | International permissions |
+15005550004 | Blocked |
+15005550006 | Valid mobile (default From) |
+15005550008 | No voice |
+15005550009 | Non-mobile (Verify may fail) |
Seeds and initial state
There is no bundled otp-flow seed file. Options:
| Approach | Example |
|---|---|
| Empty | Default Verify service; provision numbers via API |
| Admin JSON seed | POST /_clone/seed with { "phone_numbers": [{ "number": "+15005550006" }] } |
| Dashboard preset | Phone OTP signup (twilio + auth) in the preset library |
The seed string on start() controls deterministic OTP codes and account SIDs.
Limits
| Limit | Detail |
|---|---|
| OTP lookup | lastOTP() / admin GET /_clone/twilio/otp/{runId}?to=... — deterministic per run |
| Message delivery | Advance clock (3s typical) to reach delivered |
| Chaos presets | invalid_number, verify_expired, status_callback_fail |
Cross-clone flows
Phone OTP signup: combine Twilio + Auth clone. Use the Phone OTP signup preset in the dashboard library.
Environment variables
MOLAR_CLONE_TWILIO_URL, MOLAR_CLONE_TWILIO_ADMIN_URL