Skip to main content

How to use Voicemail Detection

In this guide we will show you how to use voicemail detection for calls. Please ensure you have followed our earlier guide on how to make an outbound call with Bandwidth.

Voicemail detection allows you to see if a call is answered by a person or was sent to Voicemail allowing for better use of automated call routing. Additionally, if you design workflows and processes that are directly impacted by who's answering the phone.

There are two available methods for voicemail detection, synchronous (sync) or asynchronous (async) mode. Depending on your needs, async mode can be used to allow a human to interact with the application to minimize silence experienced by the caller while waiting for answering machine detection to complete. If a subsequent machineDetectionComplete callback indicates that an answering machine answered the call, the application can respond with instructions to modify the call flow. Use sync mode if you want your application to wait until machine detection is complete regardless of whether a human or answering machine answered the call.

Async mode

When using the async mode, once the machine detection operation is completed, you will receive a machineDetectionComplete callback.

If async mode is selected, the callbackUrl needs to be specified. Also, you need to return proper BXML on the answer callback in order for the call to not be hung up until the operation is complete hence this is a required field.

Note: Remember to add authentication for your application if needed!

POST https://voice.bandwidth.com/api/v2/accounts/{accountId}
POST https://voice.bandwidth.com/api/v2/accounts/{accountId}
{
"from": "{FROM_NUMBER}",
"to": "{TO_NUMBER}",
"answerUrl": "http://example.com/answer",
"username": "{BANDWIDTH_USERNAME}",
"password": "{BANDWIDTH:PASSWORD}",
"machineDetection": {
"mode": "async",
"detectionTimeout": 15,
"silenceTimeout": 10,
"speechThreshold": 10,
"speechEndThreshold": 5,
"delayResult": false,
"callbackUrl": "http://example.com/machineDetectionCallback",
}
}

Sync mode

When using the sync mode, the answer callback is delayed until the machine detection operation is completed. Also, you will not receive a machineDetectionComplete callback in this case.

The only thing needed to use the sync mode is to set the mode itself, since the default is async.

Note: Remember to add authentication for your application if needed!

POST https://voice.bandwidth.com/api/v2/accounts/{accountId}
POST https://voice.bandwidth.com/api/v2/accounts/{accountId}
{
"from": "{FROM_NUMBER}",
"to": "{TO_NUMBER}",
"answerUrl": "http://example.com/answer",
"username": "{BANDWIDTH_USERNAME}",
"password": "{BANDWIDTH:PASSWORD}",
"machineDetection": {
"mode": "sync",
"detectionTimeout": 15,
"silenceTimeout": 10,
"speechThreshold": 10,
"speechEndThreshold": 5,
"delayResult": false,
}
}

Where to next?

Now that you have learnt to see if the call is answered by voicemail, check out some of the available actions in the following guides: