How to Make Outbound Inbound Call on Softphone Using Twilio Voice

One of the most aspects of communication is the ability to make call and receive calls, businesses can now use softphones to make outbound and inbound calls. Softphones is an excellent alternative to traditional hardphone telephony systems,  softphones  will install to your computer device and allow to make calls from your laptops, desktops, and mobile devices.

Twilio Voice is one of the most popular calling solutions available in the market today.  Twilio It is a cloud based platform that allows to make and receive calls from anywhere in the world using internet connection. Of course there have other VOIP provider out there, but this is case will  use Twilio.v

In the previous tutorial titled “How to get US Phone Number for your Business with Twilio” we purchased a US number via Twilio, and now in this PART 2, will configure the US phone number that we purchased.

In this tutorial i will walk through on how to making outbound and inbound calls using Zoiper softphone and Twilio Voice and make your first call.

Step 1: Create Credentials

Create Credentials first, Go to Voice Section, under Manage, then Credential lists, click the plus sign to add…

In this popup, add your friendly name, username and strong password, then save..

Step 2: Inbound Settings

After creating credentials go to Sip domains, under Voice section…

In This Sip Domain section, you must input the friendly name and SIP URI and be must available, i my case istocktools.sip.twlio.com is available, and the credential lists.

Sip Registration must be enabled and added credential lists

The important here is the A call comes in, this is a php code hosted in twilio, add your callerId which is your twilio phone number

http://nethram.com/sandbox/callbackweb/calltwiliosip.php?callerId=+YOUR_US_NUMBER

or if you prefer to host your own webhook code, here’s the code below

<?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 } ?>

Step 3: Outbound Settings

To set the outbound, go to Phone numbers, then Active numbers and click your phone number…

In this section you need to add webhook url.

this url is hosted in twilio, don’t forget to add your SIP user by localized URI in my case which is [email protected], this user is example only.

http://nethram.com/sandbox/callbackweb/[email protected]

or if you prefer to host your own webhook code, here’s the code below

<?php
echo header('content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
/** Get sip endpoint list **/
$params			=$_REQUEST['SipUser'];
$toNumberList	=explode(",",$params);

?>
<Response>
    <?php
    for($i=0; $i < sizeof($toNumberList) ;$i++) { $to=$toNumberList[$i]; ?>
        <Dial timeout="20">

            <Sip>
                <?php echo $to; ?>
            </Sip>

        </Dial>
        <?php } ?>
</Response>

Step 4: Install Zoiper Softphone

Go to Zoiper and download the softphone and install

add the username and password, this credential you create in Twilio

Add your SIP user localized URI, in my case [email protected]

Skip this…

AS you see the SIP TCP must be found…

Now test the outbound and inbound call, and it should be worked.

In conclusion, Twilio Voice service offers a solution for making outbound and inbound calls on a softphone. By following this tutorial step by step outlined, you can set up your Twilio account, configure your Twilio phone number, and start making and receiving calls right away.

With Twilio Voice, you can streamline your call business operations to provide excellent customer service. Whether you’re a small business or a large enterprise, Twilio Voice can help you take your customer interactions to the next level.