Skip to content

Forward Twilio Account Phone Calls to Phone Number with Correct Caller ID

by Jon on July 16th, 2013

I wrote this script to go along with the sms forwarding script so if someone called or txt one of my old phone numbers it would get forwarded to my current mobile phone number. I have moved from a few different areas and each time I like to get a new local phone number so to keep my old phone numbers I port them to twilio and am able to forward calls and txt’s to my mobile phone.

The first step is to get a copy of the twilio php library at the following github page:

Once you have a copy of the library make sure to have the directory in your development environment. See below for the sample code to forward phone calls using the caller id number of the person calling. I keep the caller id number intact to show the person who is calling me which makes it easier to know who called.

require_once 'Services/Twilio.php';

switch ($_REQUEST['To'])
case "+1407NXXXXXX": // your twilio #
$phone_number = "1941NXXXXXX"; // phone # to send call to

case "+1800NXXXXXX":
$phone_number = "1413NXXXXXX";

$response = new Services_Twilio_Twiml();
$response->dial($phone_number, array("callerId" => $_REQUEST['From']));
print $response;

Once you host the script on a web server it just requires pointing the phone number in the twilio account settings as seen below.


From → Internet, Linux, VOIP

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS

%d bloggers like this: