Raza Nazir
Raza Nazir

Reputation: 21

Making call on two different numbers using Twilio

I wish to call my customer through user interface using your API, I have 3 parameters 1st: customer number, 2nd: twilio number,3rd: my actual mobile number both of us me and my customer should see the twilio number as caller id. Can you help me get through with this? My current code is below:

$client = new Services_Twilio($AccountSid,$AuthToken);
$from = $from_ctn_code.$ctc->from;
$to = $to_ctn_code.$ctc->to;
try {
$call = $client->account->calls->create($from,$to,$url.'callback.php?number='.$from);
$ctc->sid = $call->sid;
$ctc->call_logs();
} catch (Exception $e) {

}

Upvotes: 0

Views: 259

Answers (1)

xmjw
xmjw

Reputation: 3434

Twilio Evangelist here.

We call this 'anonymous calling', and it's pretty easy to get started. You want to make a call to yourself using the code you posted above and your Twilio number as the $from parameter. Then the URL you provide needs to link to a TwiML document that will cause Twilio to connect to your customer. You need a PHP script with the following TwiML (XML)

<Response>
  <Dial callerId="<?php echo $twilio_number ?>">
     <?php echo $customer_number ?>
  </Dial>
</Response> 

This way, Twilio will call you showing the Twilio number, then call your customer showing the Twilio number (hence the callerId= attribute).

There's a good walkthrough on making calls on twilio.com. The key thing here is to use the Twilio number as the from/callerId in both cases, to give you anonymous calling.

Hope this helps.

Upvotes: 1

Related Questions