2-way Masked Phone Number SMS C

by twilio-labs

GitHub Readme.md


Masked Phone Numbers over SMS with Conversations

Actions Status


Twilio Conversations allows you to build virtual spaces ("conversations") to communicate across multiple channels.

This application shows how to add multiple external phone numbers to a Twilio Conversation and track their activity.

Implementations in other languages:


How it works

This application creates a single conversation and provides a page to manage phone numbers in the conversation. Using a webhook it tracks the activity of every phone number in the conversation. When a phone number is idle for longer than its expiration time it's removed from the conversation.


Set up


Twilio Account Settings

This application should give you a ready-made starting point for writing your own conversations application. Before we begin, we need to collect all the config values we need to run the application:

Config Value Description Account Sid Your primary Twilio account identifier - find this in the Console. Auth Token Used to authenticate - just like the above, you'll find this here. Phone number A Twilio phone number in E.164 format - you can get one here

Local development

After the above requirements have been met:

  1. Clone this repository and cd into it

    git clone git@github.com:twilio-labs/sample-conversations-masked-numbers.git
    cd sample-conversations-masked-numbers
  2. Install dependencies

    npm install
  3. Set your environment variables

    npm run setup

    See Twilio Account Settings to locate the necessary environment variables.

  4. Run the application

    npm start

    Alternatively, you can use this command to start the server in development mode. It will reload whenever you change any files.

    npm run dev

    Your application is now accessible at http://localhost:3000

  5. Make the application visible from the outside world.

    Your application needs to be accessible in a public internet address for Twilio to be able to connect with it. You can do that in different ways, deploying the app to a public provider or using ngrok to create a tunnel to your local server.

    If you have ngrok installed to open a tunnel to you local server run the following command

    ngrok http 3000

    Now your application should be available in a url like:


That's it! Now you can start adding phone numbers to the conversation.


You can run the tests locally by typing:

npm test

Cloud deployment

Additionally to trying out this application locally, you can deploy it to a variety of host services. Here is a small selection of them.

Please be aware that some of these might charge you for the usage or might make the source code for this application visible to the public. When in doubt research the respective hosting service first.

Service Heroku Deploy Glitch Remix on Glitch



This application is open source and welcomes contributions. All contributions are subject to our Code of Conduct.

Visit the project on GitHub




No warranty expressed or implied. Software is as is.