Skip to content

feat: add Twilio SMS, voice, and verification emulator#63

Open
mvanhorn wants to merge 2 commits intovercel-labs:mainfrom
mvanhorn:feat/twilio-emulator
Open

feat: add Twilio SMS, voice, and verification emulator#63
mvanhorn wants to merge 2 commits intovercel-labs:mainfrom
mvanhorn:feat/twilio-emulator

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

@mvanhorn mvanhorn commented Apr 8, 2026

Summary

Add @emulators/twilio package with full Twilio REST API emulation for SMS, voice calls, and the Verify API (2FA verification codes). Includes an inspector UI with tabs for messages, verifications, and calls.

Why this matters

Nearly every app with user authentication needs SMS verification or 2FA. Testing these flows currently requires hitting production Twilio (costs money per SMS, slow, unreliable in CI) or mocking at the HTTP level. No existing API emulator covers Twilio.

With this emulator, the full auth flow can run locally: OAuth sign-in (GitHub/Google emulator) -> phone verification (Twilio emulator) -> welcome email (Resend emulator). All without network access.

Changes

New package: @emulators/twilio

Messages API (/2010-04-01/Accounts/:sid/Messages.json):

  • POST to send SMS (generates realistic SIDs, tracks segments)
  • GET to list messages
  • GET /:sid to fetch a single message

Calls API (/2010-04-01/Accounts/:sid/Calls.json):

  • POST to create a call record
  • GET to list calls

Verify API (/v2/Services/:sid/Verifications and VerificationCheck):

  • POST Verifications to generate a 6-digit code (configurable length)
  • POST VerificationCheck to validate the code
  • Codes expire after 10 minutes
  • Wrong codes leave status as "pending" rather than consuming the attempt

Inspector UI (/):

  • Tabbed interface (Messages, Verify, Calls) using shared renderInspectorPage
  • Verification codes displayed in plain text for easy testing

Seed config:

twilio:
  account_sid: AC_test_account
  phone_numbers: ["+15551234567"]
  verify_services:
    - sid: VA_test_service
      friendly_name: "My App Verify"

Integration

  • Registered twilio in SERVICE_REGISTRY (packages/emulate/src/registry.ts)
  • Added @emulators/twilio as dev dependency of emulate
  • Updated README.md with Twilio in the service list
  • Created skills/twilio/SKILL.md with endpoint docs and examples

Demo

twilio-demo

Shows sending an SMS, creating a verification code, and checking the code (approved). All local, no real SMS sent.

Testing

6 tests pass (4 existing + 2 new for Twilio):

  • twilio sends SMS and lists messages - Messages API
  • twilio verify sends code and checks it - Verify API with code extraction from inspector UI

This follows the same pattern as our previous service emulator PRs (#4 Stripe, #7 Resend, #10 Slack).

This contribution was developed with AI assistance (Claude Code).

Add @emulators/twilio package with endpoints for the Twilio Messages
API (send, list, get), Calls API (create, list), and Verify API (send
verification code, check code). Includes an inspector UI with tabs
for messages, verifications, and calls.

Verification codes are generated server-side and visible in the
inspector UI, making it straightforward to test 2FA flows without
sending real SMS.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 8, 2026

@mvanhorn is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

- **Apple** on `http://localhost:4004`
- **Microsoft** on `http://localhost:4005`
- **AWS** on `http://localhost:4006`
- **Twilio** on `http://localhost:4007`
Copy link
Copy Markdown
Contributor

@vercel vercel bot Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README documents incorrect port numbers for AWS (4006 instead of 4007) and Twilio (4007 instead of 4012), and is missing 5 services (Okta, Resend, Stripe, MongoDB Atlas, Clerk) from the port list.

Fix on Vercel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant