Build the future of communications.
Start building for free

Set Up an SMS Forwarding Number in 5 Minutes with Twilio

There is a variety of scenarios where you want to forward SMS from a Twilio number to your cell phone. It could be when you don’t want to give your real number in an online sale or to avoid losing access to your 2FA protected account if you lose your phone. With TwiML Bin and its new templating functionality you can build an app in less than 5 minutes that will forward all incoming messages to any SMS-capable phone.

Before we get started, make sure you have a Twilio account (you can get one here) and that you are logged into the Console.

Writing the TwiML Code

Create a new TwiML Bin in your developer console.

create-twiml-bin.gif twiml-basics.png

Give your TwiML bin a name like “SMS Forwarder” and paste the following code into it:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Message to="+49111111111111">
    {{From}}: {{Body}}
  </Message>
</Response>

Replace the +49111111111111 with your own phone number including your country code in the E.164 format that you want to send the SMS to. Afterwards click “Create” to save your new TwiML Bin.

Configuring a Phone Number

Buy a new Twilio phone number or configure an existing one to point to your TwiML Bin for incoming SMS.
twiml-configuration

Now when an SMS comes in, the TwiML Bin will be triggered and the {{From}} will be replaced with the sender’s phone number and the {{Body}} with the content of the SMS. The returned TwiML instructs Twilio to send a new SMS to your cell phone with the body of the received SMS and the sender’s phone number.

Give it a spin and ask a friend to send you an SMS to your Twilio number and you should now receive SMS sent to that Twilio number on your own cell phone. And all in just 6 lines of XML.

Just the Beginning

The power of TwiML is huge and the applications vast. If you want to learn more about TwiML you should check out:

I would love to hear and see what you built with it! So feel free to drop me a line:

Authors
Sign up and start building
Not ready yet? Talk to an expert.