Skip to main content

How to Modify Calls in Progress

In this guide we will show you how to modify the BXML for a call already in progress. Please ensure you have followed our earlier guide on how to make an outbound call with Bandwidth. It is recommended to use a request manager like POSTMAN for this tutorial, but the SDKs are also capable.

Bandwidth’s /calls API provides the capability of modifying the call flow by sending new BXML to an active call. An example of when you may want to modify an active call is an inbound call center application where you place a customer in a “waiting room” by playing hold music while waiting for an agent to become available. Once an agent becomes available you can send replacement BXML for the call to be transferred to the available agent. As an enhancement you could send BXML in the interim to indicate to the caller the estimated time until an agent is available by playing text to speech and resuming the hold music.

Modify a Live Call

You can modify both an inbound or outbound live call by providing a new set of instructions via BXML. Please note that modifying a call will end any verbs currently executing and will skip any subsequent ones.

You will need to interrupt an active call by calling our REST API endpoint. In this example, we will create an outbound call that pauses for 1 minute. This will give you time to copy the callId and modify the call.

<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Pause duration="60" />
</Response>

When the outbound call is placed, you will need to make a note of the callId for this call as it will be used to modify the active call.

API for Call Modification

In this example, the BXML that is in the redirectUrl will immediately replace all verbs present on the current call with the new text-to-speech sentence.

//Note: remember to add auth for your application if needed!

POST https://voice.bandwidth.com/api/v60/accounts/{YOUR_ACCOUNT_ID}/calls/{THE_CALL_ID}
{
"redirectUrl": "/goodbyeMessage",
}

/goodbyeMessage should serve the following:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
<SpeakSentence>
Thank you for holding! Goodbye!
</SpeakSentence>
</Response>

Where to next?

Now that you have learnt how to modify existing calls in progress, check out some of the available actions in the following guides: