How to Test Your Twilio App from India Using Twilio Dev Phone

Developer testing Twilio app from India
November 18, 2022
Written by
Liz Moy
Reviewed by

There are few things more frustrating than sending a test message or call to your application and not getting through – especially if you check the Twilio logs and see that your call or message never reached the number. If you’re a developer in India, your development process might be running up against some special telephony restrictions.

It is important to understand India’s messaging limitations before you consider developing an app to send SMS to Indian mobile devices. However, if you just need to test an application that is being developed for deployment in other countries, the Twilio Dev Phone is a great solution.

Limitations of Twilio SMS to Indian mobile devices

When sending messages to India from Twilio, your Twilio phone number won’t appear as the sender of the message: the sender ID will be changed by the carrier before your SMS messages are delivered to end users. Usually if you are testing functionality from your own device, you will see a random short number between 5 and 9 digits long, e.g., 5NNNN - 5NNNNNNN.

Because of the sender ID change, a recipient can’t send a reply back to your Twilio phone number. If you’re building your app in production with the intent to utilise two-way messaging with mobile users in India, consider using the Twilio API for WhatsApp instead.

How Twilio Dev Phone can help you test your application

It is important to understand the above limitations before you consider deploying an app to send messages to Indian mobile users. However, if you are a developer in India working on an app and just need to to test what you’re building, you can do so using the Twilio Dev Phone. The Dev Phone is a virtual phone that uses a Twilio number to send/receive calls and SMS messages.

In this post, you will learn how to set up the Twilio Dev Phone, make a call from the dev phone to your application and send an(?) SMS to your application with an automated response using Twilio Studio.


Set up the Dev Phone

The Twilio Dev Phone allows you to test your voice and messaging applications without having to use your own device to do so. If you are in India and running into issues using your own device for testing purposes, you can use the Dev Phone instead. This will work by using the phone number you purchased to connect to code that runs the Dev Phone.

First, open up your terminal and check to make sure that you have installed or updated to the latest version of twilio-cli.

If if is your first time using the CLI, you can create a new profile to store your Twilio Account credentials and configuration by running the following command

twilio profiles:create

You will then be prompted to enter your Account SID and Auth Token, and to give your profile a shorthand identifier. To choose this profile, run the below command with the shorthand identifier you chose:

twilio profiles:use your-identifier-here

Next, add the Dev Phone plugin using the following command:

twilio plugins:install @twilio-labs/plugin-dev-phone

If you have run the Dev Phone previously on this profile, you may receive the following error:

The plugin "@twilio/plugin-dev-phone" contains a conflicting command name: dev-phone

If this happens, you may uninstall the plugin using the below command, and then re-install it.

twilio plugins:uninstall
twilio plugins:install @twilio-labs/plugin-dev-phone

Run the Dev Phone

To run the Dev Phone, enter the below command:

twilio dev-phone

You should see the below in your terminal as the Dev Phone starts up.

Hello 👋 I'm your dev-phone and my name is dev-phone-XXXXXX

✅ I'm using your profile API key.

💻 Creating a new conversation...
✅ I'm using the conversation CHXXXXXXXX from service ISXXXXXXXX

💻 Creating a new sync list for call history...
✅ I'm using the sync service ISXXXXXXXX

💻 Deploying a Functions Service to handle incoming calls and SMS...
✅ I'm using the Serverless Service ZSXXXXXXXX

💻 Creating a new TwiMl App to allow voice calls from your browser...
✅ I'm using the TwiMl App APXXXXXXXX

🚀 Your local webserver is listening on port 1337
🌐 Opening http://localhost:1337/ your browser
▶️  Use ctrl-c to stop your dev-phone

If you already have something running on that port or wish to use a different port, you can:

  1. Define a port passed in as a flag
  2. Define a port passed in via the TWILIO_DEV_PHONE_PORT environment variable

Once this is running, it should auto-launch in your browser and you will see the below page. Notice in the upper right hand corner that there is no Twilio number yet selected for the Dev Phone.

A screenshot of the welcome display when the dev phone opens in the browser

Next, scroll down and you will see a configuration selection to choose a number. If you bought a number as a part of the prerequisites, you may choose that number from the drop down. If you haven’t purchased one yet, you can do so now, and then refresh the page. Click Use this phone number.

Select a phone number to associate with the Dev Phone

Now your Dev Phone is ready to use for incoming and outgoing calls and messages.

A set up Twilio Dev Phone

During the setup a few Twilio Functions were created and deployed that provide the functionality for the Dev Phone to make and receive calls and messages. If you open up the Services part of your console, you can see where these functions were auto-generated.

Services set up for a Twilio Dev Phone install

Your dev phone number is connected to these functions. As long as you use this number as your Dev Phone number, you will not want to change anything in the configuration.

In the screenshots below, you can see the number is already connected to your functions service. Do not change this, or else your Dev Phone will break. Buy a new number in order to connect it to the app you are building.

Automatic Dev Phone setup for Messaging

Automatic Dev Phone setup for Voice

If it will help you to remember – and you plan to use this number for the dev phone again in the future – you can also rename the “friendly name” for your Dev Phone number to something like dev-phone, which will render in the dev phone UI the next time you see the phone number selection screen.

Friendly name for the Dev Phone

Next, you will set up your new number to use for your application. Then you will test calling and messaging it from your Dev Phone

Call Your App from the Dev Phone

Buy a new number that you will use for your app (and feel free to change the friendly name to keep them distinct). Then, go to the Studio part of your console and create a new flow.

Create a new Flow for the Dev Phone

Choose Start from scratch.

Start from Scratch on a Flow

Now input a greeting message using the Say/Play widget. Connect it to the Incoming Call option from the Trigger widget. Hit Publish.

Add a Say/Play widget

Navigate back to the Active Numbers part of your console and choose your app number. Scroll down to the Voice configuration. From the A Call Comes In dropdown, choose Studio. In the dropdown next to it, choose the flow you just created.

Picking a Voice & Fax Webhook with the Studio Flow

Go back to the localhost window running your Dev Phone. Paste in the app number and test out a call. You should hear your greeting playback, and you will see call information in the Call History section.

Preview of message and voice history on the Dev Phone

Message Your App from the Dev Phone

Go back to your same Studio flow. This time, add a Send Message widget with a greeting and connect it to the Incoming Message section of the Trigger widget. Hit Publish.

Adding messaging support to the Dev Phone

Navigate to the Messaging configuration in your app number. Follow the same steps as we did for Voice: Choose Studio from the dropdown and your flow in the subsequent dropdown. Hit Save.

Messaging webhook for the Dev Phone

If you get an error like the below, be sure to check your SMS geo permissions and update them accordingly. For example, since I set up my Twilio account in the UK, I was not opted in to receive messages from a US number, even if the country code for the number that I purchased was a US number.

SMS API threw an error TwilioCliError: Error code 21408 from Twilio: Permission to send an SMS has not been enabled for the region indicated by the 'To' number: +19496945346.

Go back to your Dev Phone and try sending a SMS message. It should look like the image below. Now your dev phone and application are working together!

Message history in the Dev Phone


If you are building with Twilio in India or another country with SMS restrictions, using the dev phone could help you get around regulatory hurdles that make it hard to test your app. When you are setting up your application, be sure to keep the dev phone separate from your application number; use the friendly names to your advantage.

In the next post you will learn how you can trigger an outbound message from your application to the dev phone using Postman and the REST API Trigger widget in Twilio Studio. This will also help with mocking up what an automated or scheduled call or message could look like.

If you’re building something and use the dev phone to test, we want to hear about it! Email me lmoy[at] to let me know, and send me a tweet of your messages.

Liz Moy is a Developer Evangelist on the Enterprise Evangelism team. She loves to talk to developers at hackathons, conferences, and on the Build and Deploy with Liz Moy podcast. You can find her at lmoy [at] or on Twitter @ecmoy.