TwilioLeroy Chan18 min readtutorialintermediate
On-Demand Masked Sessions with Twilio Proxy, Voice and Serverless
Summary
A step‑by‑step tutorial showing how to build a Just‑in‑Time masked‑call workflow with Twilio Voice, Proxy, and Sync, using a two‑bounce out‑of‑session pattern to collect a tracking code via IVR, resolve the counterpart’s number, stash it in Sync, and auto‑create a Proxy session on the fly—all deployed as Twilio Serverless Functions.
- Use Twilio Proxy’s out‑of‑session callback to intercept calls on a single reserved number.
- Collect a 6‑digit tracking code with a `<Gather>` prompt, look up the counterpart via a Sync map, and store the resolved number in a temporary Sync Document (keyed by `res‑<CallSid>`).
- Redirect the call back to Proxy (second bounce) where the stored resolution is read, the Sync document is deleted, and Proxy auto‑creates the masked session.
- All logic lives in five Serverless endpoints (`/out-of-session`, `/gather-action`, `/lookup`, etc.) and a small TypeScript helper library for Sync CRUD.
Marketplace and on‑demand services often cannot pre‑assign phone numbers to every participant. This pattern lets a single pool number handle unlimited ad‑hoc connections while preserving privacy, reducing inventory pressure, and keeping the user experience frictionless for couriers or drivers.
6/10


