Skip to main content

DevStack, Messaging, Voice

Unleash the power of Bandwidth with BXML


December 16, 2015


March 29, 2023

elderly woman lifting weights

Bandwidth provides an API to programmatically control phone numbers. What started as a fun idea, has grown into a massive service powering all sorts of businesses.

Traditionally, you would have to control each and every leg of a call flow with the REST API. While this is approach is incredibly powerful and flexible, you probably don’t need to manage all that yourself.

The REST API — Great power = Great Responsibility

Traditional Call Forward Flow with REST

Enter BXML (Bandwidth XML)

BXML is simply an XML document generated by your server (or you for simple use-cases) that instructs the Bandwidth Servers on how to handle your call/sms. BXML is almost always going to reduce your complexity and in some cases improve performance.

When the XML document is retrieved by Bandwidth, sll of the actionable contacts are handled by Bandwidth internally. This results in an decreased latency which makes the customer interactions more ‘snappy.’

Traditional Call Forward with BXML

Where BXML Really Shines

BXML can potentially make any call flow more straightforward. But it really shines when managing conference calls and simulring (ringing multiple phones and connecting the first to answer). Simulring via the REST API can ring unlimited phones and connect the first to answer. However, making each call, waiting for an answer event, answering the call, ending the other calls, bridging the two call legs, hanging up the calls when conversation is over, and ending the bridge is ALL handled in your application. If you only need to simulring a few phones, BXML is your new best friend!

You and BXML

All of that above complexitiy can be contained in a single BXML document.

This call has been forwarded.

Hacking up BXML with Github Gists

To demonstrate just HOW easy BXML can be. You don’t even need a server to get started with Bandwidth any more. You can hack up a simple call flow using Github Gists and BXML.

  1. Create a new Bandwidth Phone Number
How to order a new number

2. Create a new Gist similar to the one below. Set the ‘transferCallerId’ value to the phone number you just ordered, set the ‘transferTo’ value to your cell phone, and name the end the file name with ‘.xml.’

Transferring your call, please wait.  
Someone is calling you.

3. Copy the RAW XML location from Github

Make sure the file ends in .xml

4. Create a new application with the new phone number in the Bandwidth Console. Set the CALL URL to the RAW XML location from github. Set the HTTP method to GET and make sure that Auto-Answer is set to True. Then assign the newly ordered number to the Application.

Create new application with Raw Gist location and set the HTTP Method to GET. Keep Auto-answer enabled

5. Call your new Bandwidth number and watch your cell phone ring! Woah!

Learn More

So by now you’re thinking: “Wow, that’s totally easy! Where can I learn more?” Just head over to our ‘How-to’ Guides to get started easily.