In short, I have a Twilio Elastic SIP Trunk and configured my PBX (Asterisk) to make outbound calls through the SIP Domain on Twilio; when logging into Twilio I have the option of configuring the SIP Domain's voice configuration URL so when a call is dialed out, the script passes the call to its destination.
For whatever reason, it used to pass the original caller ID of the person when I forward a call out but now it keeps overwriting the Caller ID with my office's number; essentially masking the original caller's caller ID when a call is transferred out; this is pretty annoying and I'm trying to figure out the best way to resolve it.
My goal is to fix outbound dialing so when a call is transferred externally, the caller ID of the individual should display instead of my office's number;
The Twiml config I have for my SIP Domain's voice URI looks like this:
<?php
echo header('content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
$to=$_REQUEST['To'];
$callerId=$_REQUEST["callerId"];
/** Extracting user name **/
$pos1 = strpos($to,":");
$pos2 = strpos($to,"@");
$tosip=substr($to,$pos1+1,$pos2-$pos1-1);
if(strlen($tosip) == 3)
{
/**Extracting sip endpoint**/
$pos2 = strpos($to,":",strpos($to,":")+1);
$tosip=substr($to,$pos1+1,$pos2-$pos1-1);
?>
<Response>
<Dial>
<Sip>
<?php echo $tosip; ?>
</Sip>
</Dial>
</Response>
<?php } else { if(substr($tosip,0,2)=="00") $tosip=substr($tosip,2,strlen($tosip)-1); if(substr($tosip,0,3)=="011") $tosip=substr($tosip,3,strlen($tosip)-1); ?>
<Response>
<Dial callerId="<?php echo $callerId; ?>" >
<?php echo $tosip; ?>
</Dial>
</Response>
<?php } ?>
To successfully pass the call I have to make the $GET param for CallerId my office's number; but this overwrites the original caller ID; it used to be I could simply call the verb and the original caller ID would appear; but now it doesn't seem the case.
Any advice or point in the right direction appreciated!