Twilio API

IDT Enterprise BYOC Twilio Configuration Guide

 

Setup Trunk

In Twilio, navigate to Voice, and under Manage, click on BYOC trunks.

byoc-trunk.png
 


Click on the blue “+” sign, then enter a BYOC trunk name (e.g., idt-enterprise-companyname), and click “Create BYOC Trunk.”

byoc-trunk-create.png


Setup Origination Connection Policy

In the Voice section of Twilio under Manage, click on Origination connection policy and then the blue “+” sign. Next, enter a name for the policy (e.g., idt-enterprise-companyname out) and click “Create.”

origination-policy-create.png

Once created, click on your newly created Origination Connection Policy, and you will see the policy’s configuration page.

origination-policy-edit.png

We will now add 2 Origination Targets. Click on the blue “+” sign and enter sip:sip.ent1.idt.net for the Origination SIP URI, leaving the rest of the values as default, and click “Create.” 

origination-target-1.png

After creating the first Origination Target, add another one with the Origination SIP URI set to sip:sip.ent2.idt.net, leaving the rest of the values as default.

origination-target-2.png

Once completed, your policy’s Origination Targets should look as follows:

origination-targets-completed.png


Assign Origination Connection Policy to Trunk

In the Voice section of Twilio under Manage, click on BYOC trunks and click on the IDT Enterprise trunk you created earlier. Then, under General Settings, within the subsection Origination Connection Policy (to your Carrier), select your newly created Origination Connection Policy and then click “Save.”

assign-policy-to-trunk.png



Making Calls via API

In the Voice section of Twilio under Manage, click on BYOC trunks, click on your IDT Enterprise trunk you created earlier, and take note of your trunk’s BYOC Trunk SID.

trunk-sid.png

Using your preferred method of calling Twilio API from Twilio API Docs, add the Byoc parameter to your call with your BYOC Trunk SID as the value. 

For example in curl:

curl --location --request POST 'https://api.twilio.com/2010-04-01/Accounts/<ACCOUNT_SID>/Calls.json' \

--header 'Authorization: Basic SUPER_SECRET' \

--header 'Content-Type: application/x-www-form-urlencoded' \

--data-urlencode 'Url=http://demo.twilio.com/docs/voice.xml' \

--data-urlencode 'To=+12345678900' \

--data-urlencode 'From=+18003331122' \

--data-urlencode 'Byoc=<BYOC_TRUNK_SID>'

 

If the call was completed successfully through BYOC interconnect, you should see the call appear in the Call Logs as BYOC type.

call-logs.png


Making Calls via SIP

To demonstrate how to make calls via SIP, we will be setting up a call forwarding example that will forward all SIP calls through our BYOC trunk.

Twilio allows you to use IP and Digest authentication to interact with your Twilio resources. In this example, we will use only IP authentication.  

Note: If your SIP client requires the use of the digest authentication method, in the Voice section of Twilio under Manage, click on Credentials lists to add user credentials. Then in the “Setup SIP Domain” section of this guide, use the newly created credential list for “voice authentication.” You will then need to enter the SIP credentials in your client to initiate calls. You can use IP or digest authentication, or a combination of both to protect your SIP domain.

Setup IP ACL

In the Voice section of Twilio under Manage, click IP access control lists, and finally, Create new IP Access Control List.

acl.png


In the Access Control List popup, enter a name, the IP address range(s), and associated friendly name(s) that you will be using to call Twilio via SIP. Then click “Create ACL.”

create-acl.png


Setup SIP Domain

Once created, under Manage, click on SIP domains and click on the blue “+” sign.

sip-domain.png


On the new page, enter a friendly name and a SIP URI that you will be using later to make calls via SIP (e.g., idt-enterprise-call-forwarding). Under IP Access Control Lists, select the IP ACL we created in the previous step. Under Call Control Configuration, choose the BYOC Trunk option for Configure With, and for BYOC Trunk selection, use the trunk we created earlier idt-enterprise-companyname. Then click “Save.”

sip-domain-create.png

Now any SIP calls made to idt-enterprise-call-forwarding.sip.twilio.com will go through the configuration settings on our BYOC trunk. As of right now, the configuration will use the “default” Twilio TwiML demo. For our call forwarding use case, we need to change the BYOC trunk to use simple call forwarding to our BYOC trunk.  

Update BYOC Trunk with Call Forwarding TwiML

In the Voice section of Twilio under Manage, click on BYOC trunks, click on your IDT Enterprise trunk you created earlier, and take note of your trunk’s BYOC Trunk SID.

trunk-sid (1).png

Under Application Configuration, select the option TwiML Bin under A Call Comes In and click on the blue “+” sign.


On the popup page, enter the TwiML that will be executed when this trunk receives calls. Enter a friendly name for the TwiML code snippet and the code on the screen, and click “Create.” In this example, we use the Dial and Number verbs in the TwiML, and we added the byoc option in the Number verb, where you can replace your BYOC Trunk SID as the value. In this example, TwiML will forward the calls using the BYOC trunk to the To number provided in the original call, utilizing Twilio’s templating feature and E.164 internal function to initiate the call.

twiml-call-forwarding.png

Once added, you will see this new TwiML Bin on the BYOC trunk page. Click on “Save.”

Make Test Call

You can now send SIP traffic through the SIP domain created (in this example, idt-enterprise-call-forwarding.sip.twilio.com). A SIP call made to 12345678900 via idt-enterprise-call-forwarding.sip.twilio.com will be call-forwarded from Twilio through your BYOC trunk, and you will see this completed call reflected in the call logs on Twilio.