Set Up an SMS Forwarding Number in 5 Minutes with Twilio
Time to read: 2 minutes
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.
Give your TwiML bin a name like “SMS Forwarder” and paste the following code into it:
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.
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:
- Set up a temporary “burner” phone number with TwiML Bins
- How to set up a conference line
- Introduction to TwiML Bin template
- The TwiML documentation
I would love to hear and see what you built with it! So feel free to drop me a line:
- Email: dkundel@twilio.com
- Twitter: @dkundel
- GitHub: dkundel
Related Posts
Related Resources
Twilio Docs
From APIs to SDKs to sample apps
API reference documentation, SDKs, helper libraries, quickstarts, and tutorials for your language and platform.
Resource Center
The latest ebooks, industry reports, and webinars
Learn from customer engagement experts to improve your own communication.
Ahoy
Twilio's developer community hub
Best practices, code samples, and inspiration to build communications and digital engagement experiences.