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.
- Request Payload
- cURL
- Java
- C#
- Ruby
- NodeJS
- Python
- PHP
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",
}
}
Note: Remember to add authentication for your application if needed!
curl 'https://voice.bandwidth.com/api/v2/accounts/{BW_ACCOUNT_ID}/calls' \
-X POST \
-u '{BANDWIDTH_USERNAME}:{BANDWIDTH:PASSWORD}' \
-H 'Content-Type: application/json' \
-d '{
"from": "{BW_NUMBER}",
"to": "{$USER_NUMBER},
"applicationId": "{APPLICATION_ID}",
"answerUrl": "{ANSWER_URL}",
"username": "{BW_USERNAME}",
"password": "{BW_PASSWORD}",
"machineDetection": {
"mode": "async",
"detectionTimeout": 15,
"silenceTimeout": 5,
"speechThreshold": 5,
"speechEndThreshold": 1,
"machineSpeechEndThreshold": 3,
"delayResult": false,
"callbackUrl": "http://example.com/machineDetectionCallback"
}
}'
import com.bandwidth.sdk.ApiClient;
import com.bandwidth.sdk.ApiException;
import com.bandwidth.sdk.Configuration;
import com.bandwidth.sdk.auth.*;
import com.bandwidth.sdk.models.*;
import com.bandwidth.sdk.api.CallsApi;
public class Sample {
public static final String USERNAME = System.getenv("BW_USERNAME");
public static final String PASSWORD = System.getenv("BW_PASSWORD");
public static final String ACCOUNT_ID = System.getenv("BW_ACCOUNT_ID");
public static void main(String[] args) {
String voiceApplicationId = System.getenv("BW_VOICE_APPLICATION_ID");
String to = System.getenv("USER_NUMBER");
String from = System.getenv("BW_NUMBER");
String baseUrl = System.getenv("BASE_CALLBACK_URL");
String answerUrl = baseUrl.concat("/answer");
ApiClient defaultClient = Configuration.getDefaultApiClient();
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
Basic.setUsername(BW_USERNAME);
Basic.setPassword(BW_PASSWORD);
MachineDetectionConfiguration amd = new MachineDetectionConfiguration();
amd.setMode(MachineDetectionModeEnum.ASYNC);
amd.setCallbackMethod(CallbackMethodEnum.POST);
amd.setDetectionTimeout(15.0);
amd.setSilenceTimeout(5.0);
amd.setSpeechThreshold(5.0);
amd.setSpeechEndThreshold(1.0);
amd.setDelayResult(false);
CallsApi apiInstance = new CallsApi(defaultClient);
CreateCall request = new CreateCall();
request.setApplicationId(voiceApplicationId);
request.setTo(to);
request.setFrom(from);
request.setAnswerUrl(answerUrl);
request.setMachineDetection(amd);
//remember to add auth for your application if needed!
try {
CreateCallResponse result = apiInstance.createCall(BW_ACCOUNT_ID, request);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling CallsApi#createCall");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
using System;
using System.Threading.Tasks;
using Bandwidth.Standard;
using Bandwidth.Standard.Exceptions;
using Bandwidth.Standard.Voice.Models;
class Program
{
static async Task Main(string[] args)
{
var username = System.Environment.GetEnvironmentVariable("BW_USERNAME");
var password = System.Environment.GetEnvironmentVariable("BW_PASSWORD");
var accountId = System.Environment.GetEnvironmentVariable("BW_ACCOUNT_ID");
var applicationId = System.Environment.GetEnvironmentVariable("BW_VOICE_APPLICATION_ID");
var to = System.Environment.GetEnvironmentVariable("USER_NUMBER");
var from = System.Environment.GetEnvironmentVariable("BW_NUMBER");
var baseUrl = System.Environment.GetEnvironmentVariable("BASE_CALLBACK_URL");
var answerUrl = string.Concat(baseUrl, "/answer");
MachineDetectionConfiguration amd = new MachineDetectionConfiguration() {
CallbackUrl = "http://example.com/machineDetectionCallback",
Mode = ModeEnum.Async,
CallbackMethod = CallbackMethodEnum.POST,
DetectionTimeout = 15.0,
SilenceTimeout = 5.0,
SpeechThreshold = 5.0,
SpeechEndThreshold = 1.0,
DelayResult = false
};
var client = new BandwidthClient.Builder()
.VoiceBasicAuthCredentials(username, password)
.Build();
var request = new CreateCallRequest()
{
ApplicationId = applicationId,
To = to,
From = from,
AnswerUrl = answerUrl,
MachineDetection = amd
//remember to add auth for your application if needed!
};
try
{
var response = await client.Voice.APIController.CreateCallAsync(accountId, request);
Console.WriteLine(response.Data);
}
catch (ApiException e)
{
Console.WriteLine(e.Message);
}
}
}
require 'bandwidth-sdk'
begin
BW_USERNAME = ENV.fetch('BW_USERNAME')
BW_PASSWORD = ENV.fetch('BW_PASSWORD')
BW_ACCOUNT_ID = ENV.fetch('BW_ACCOUNT_ID')
BW_VOICE_APPLICATION_ID = ENV.fetch('BW_VOICE_APPLICATION_ID')
BW_NUMBER = ENV.fetch('BW_NUMBER')
USER_NUMBER = ENV.fetch('USER_NUMBER')
BASE_CALLBACK_URL = ENV.fetch('BASE_CALLBACK_URL')
rescue
p 'Please set the environmental variables defined in the README'
exit(-1)
end
Bandwidth.configure do |config|
config.username = BW_USERNAME
config.password = BW_PASSWORD
end
calls_api_instance = Bandwidth::CallsApi.new
amd_config = Bandwidth::MachineDetectionConfiguration.new(
mode: Bandwidth::MachineDetectionModeEnum::ASYNC,
callback_url: BASE_CALLBACK_URL + '/machineDetection',
callback_method: Bandwidth::CallbackMethodEnum::POST
)
call_body = Bandwidth::CreateCall.new(
application_id: BW_VOICE_APPLICATION_ID,
to: USER_NUMBER,
from: BW_NUMBER,
answer_url: BASE_CALLBACK_URL + '/answer',
machine_detection: amd_config
)
begin
result = calls_api_instance.create_call(BW_ACCOUNT_ID, call_body)
p result.call_id
rescue Bandwidth::ApiError => e
p e.code
end
import {
CallsApi,
Configuration,
CallbackMethodEnum,
MachineDetectionModeEnum
} from 'bandwidth-sdk';
const BW_USERNAME = process.env.BW_USERNAME;
const BW_PASSWORD = process.env.BW_PASSWORD;
const BW_ACCOUNT_ID = process.env.BW_ACCOUNT_ID;
const BW_VOICE_APPLICATION_ID = process.env.BW_VOICE_APPLICATION_ID;
const BW_NUMBER = process.env.BW_NUMBER;
const USER_NUMBER = process.env.USER_NUMBER;
const BASE_CALLBACK_URL = process.env.BASE_CALLBACK_URL;
const config = new Configuration({
BW_USERNAME,
BW_PASSWORD
});
const callsApi = new CallsApi(config);
const amdConfig = {
mode: MachineDetectionModeEnum.Async,
detectionTimeout: 5.0,
silenceTimeout: 5.0,
speechThreshold: 5.0,
speechendThreshold: 5.0,
delayResult: true,
callbackUrl: BASE_CALLBACK_URL + '/machineDetection',
callbackMethod: CallbackMethodEnum.Post
};
const callBody = {
applicationId: BW_VOICE_APPLICATION_ID,
to: USER_NUMBER,
from: BW_NUMBER,
displayName: 'NodeJS SDK',
answerUrl: `${BASE_CALLBACK_URL}/callbacks/answer`,
answerMethod: CallbackMethodEnum.Post,
disconnectUrl: `${BASE_CALLBACK_URL}/callbacks/disconnect`,
disconnectMethod: CallbackMethodEnum.Get,
machineDetection: amdConfig,
callTimeout: 30.0,
callbackTimeout: 15.0
};
const { status, data } = await callsApi.createCall(BW_ACCOUNT_ID, callBody);
import os
import bandwidth
from pprint import pprint
configuration = bandwidth.Configuration(
username=os.environ["BW_USERNAME"],
password=os.environ["BW_PASSWORD"]
)
with bandwidth.ApiClient(configuration) as api_client:
api_instance = bandwidth.CallsApi(api_client)
account_id = os.environ["BW_ACCOUNT_ID"]
machine_detection_configuration = bandwidth.MachineDetectionConfiguration(
mode=bandwidth.MachineDetectionModeEnum.ASYNC,
detection_timeout=15,
silence_timeout=5,
speech_threshold=5,
speech_end_threshold=1,
delay_result=True,
callback_url="http://example.com/machineDetectionCallback",
callback_method="POST"
)
create_call = bandwidth.CreateCall(
to=os.environ["USER_NUMBER"],
var_from=os.environ["BW_NUMBER"],
answer_url=os.environ["VOICE_CALLBACK_URL"],
application_id=os.environ["BW_VOICE_APPLICATION_ID"],
machine_detection=machine_detection_configuration
)
try:
api_response = api_instance.create_call(account_id, create_call)
print("The response of CallsApi->create_call:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling CallsApi->create_call: %s\n" % e)
require "vendor/autoload.php";
$BW_USERNAME = getenv("BW_USERNAME");
$BW_PASSWORD = getenv("BW_PASSWORD");
$BW_ACCOUNT_ID = getenv("BW_ACCOUNT_ID");
$BW_VOICE_APPLICATION_ID = getenv("BW_VOICE_APPLICATION_ID");
$BW_NUMBER = getenv("BW_NUMBER");
$USER_NUMBER = getenv("USER_NUMBER");
$VOICE_CALLBACK_URL = getenv("VOICE_CALLBACK_URL");
$config = new BandwidthLib\Configuration(
array(
'voiceBasicAuthUserName' => $BW_USERNAME,
'voiceBasicAuthPassword' => $BW_PASSWORD,
)
);
$client = new BandwidthLib\BandwidthClient($config);
$voiceClient = $client->getVoice()->getClient();
$machineDetection = new BandwidthLib\Voice\Models\MachineDetectionConfiguration();
$machineDetection->mode = BandwidthLib\Voice\Models\ModeEnum::ASYNC;
$machineDetection->callbackUrl = "http://example.com/machineDetectionCallback";
$machineDetection->callbackMethod = "POST";
$machineDetection->detectionTimeout = 15.0;
$machineDetection->silenceTimeout = 5.0;
$machineDetection->speechThreshold = 5.0;
$machineDetection->speechEndThreshold = 1.0;
$machineDetection->delayResult = true;
$body = new BandwidthLib\Voice\Models\CreateCallRequest();
$body->from = $BW_NUMBER;
$body->to = $USER_NUMBER;
$body->answerUrl = $VOICE_CALLBACK_URL;
$body->applicationId = $BW_VOICE_APPLICATION_ID;
$body->machineDetection = $machineDetection;
#remember to add auth for your application if needed!
try {
$response = $voiceClient->createCall($BW_ACCOUNT_ID, $body);
print_r($response->getResult()->callId);
} catch (BandwidthLib\APIException $e) {
print_r($e->getResponseCode());
}
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.
- Request Payload
- cURL
- Java
- C#
- Ruby
- NodeJS
- Python
- PHP
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,
}
}
Note: Remember to add authentication for your application if needed!
curl 'https://voice.bandwidth.com/api/v2/accounts/{BW_ACCOUNT_ID}/calls' \
-X POST \
-u '{BANDWIDTH_USERNAME}:{BANDWIDTH:PASSWORD}' \
-H 'Content-Type: application/json' \
-d '{
"from": "{BW_NUMBER}",
"to": "{$USER_NUMBER},
"applicationId": "{APPLICATION_ID}",
"answerUrl": "{ANSWER_URL}",
"username": "{BW_USERNAME}",
"password": "{BW_PASSWORD}",
"machineDetection": {
"mode": "sync",
"detectionTimeout": 15,
"silenceTimeout": 5,
"speechThreshold": 5,
"speechEndThreshold": 1,
"machineSpeechEndThreshold": 3,
"delayResult": false,
}
}'
import com.bandwidth.sdk.ApiClient;
import com.bandwidth.sdk.ApiException;
import com.bandwidth.sdk.Configuration;
import com.bandwidth.sdk.auth.*;
import com.bandwidth.sdk.models.*;
import com.bandwidth.sdk.api.CallsApi;
public class Sample {
public static final String USERNAME = System.getenv("BW_USERNAME");
public static final String PASSWORD = System.getenv("BW_PASSWORD");
public static final String ACCOUNT_ID = System.getenv("BW_ACCOUNT_ID");
public static void main(String[] args) {
String voiceApplicationId = System.getenv("BW_VOICE_APPLICATION_ID");
String to = System.getenv("USER_NUMBER");
String from = System.getenv("BW_NUMBER");
String baseUrl = System.getenv("BASE_CALLBACK_URL");
String answerUrl = baseUrl.concat("/answer");
ApiClient defaultClient = Configuration.getDefaultApiClient();
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
Basic.setUsername(BW_USERNAME);
Basic.setPassword(BW_PASSWORD);
MachineDetectionConfiguration amd = new MachineDetectionConfiguration();
amd.setMode(MachineDetectionModeEnum.SYNC);
amd.setCallbackMethod(CallbackMethodEnum.POST);
amd.setDetectionTimeout(15.0);
amd.setSilenceTimeout(5.0);
amd.setSpeechThreshold(5.0);
amd.setSpeechEndThreshold(1.0);
amd.setDelayResult(false);
CallsApi apiInstance = new CallsApi(defaultClient);
CreateCall request = new CreateCall();
request.setApplicationId(voiceApplicationId);
request.setTo(to);
request.setFrom(from);
request.setAnswerUrl(answerUrl);
request.setMachineDetection(amd);
//remember to add auth for your application if needed!
try {
CreateCallResponse result = apiInstance.createCall(BW_ACCOUNT_ID, request);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling CallsApi#createCall");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
using System;
using System.Threading.Tasks;
using Bandwidth.Standard;
using Bandwidth.Standard.Exceptions;
using Bandwidth.Standard.Voice.Models;
class Program
{
static async Task Main(string[] args)
{
var username = System.Environment.GetEnvironmentVariable("BW_USERNAME");
var password = System.Environment.GetEnvironmentVariable("BW_PASSWORD");
var accountId = System.Environment.GetEnvironmentVariable("BW_ACCOUNT_ID");
var applicationId = System.Environment.GetEnvironmentVariable("BW_VOICE_APPLICATION_ID");
var to = System.Environment.GetEnvironmentVariable("USER_NUMBER");
var from = System.Environment.GetEnvironmentVariable("BW_NUMBER");
var baseUrl = System.Environment.GetEnvironmentVariable("BASE_CALLBACK_URL");
var answerUrl = string.Concat(baseUrl, "/answer");
MachineDetectionConfiguration amd = new MachineDetectionConfiguration() {
Mode = ModeEnum.Sync,
CallbackMethod = CallbackMethodEnum.POST,
DetectionTimeout = 15.0,
SilenceTimeout = 5.0,
SpeechThreshold = 5.0,
SpeechEndThreshold = 1.0,
DelayResult = false
};
var client = new BandwidthClient.Builder()
.VoiceBasicAuthCredentials(username, password)
.Build();
var request = new CreateCallRequest()
{
ApplicationId = applicationId,
To = to,
From = from,
AnswerUrl = answerUrl,
MachineDetection = amd
//remember to add auth for your application if needed!
};
try
{
var response = await client.Voice.APIController.CreateCallAsync(accountId, request);
Console.WriteLine(response.Data);
}
catch (ApiException e)
{
Console.WriteLine(e.Message);
}
}
}
require 'bandwidth-sdk'
begin
BW_USERNAME = ENV.fetch('BW_USERNAME')
BW_PASSWORD = ENV.fetch('BW_PASSWORD')
BW_ACCOUNT_ID = ENV.fetch('BW_ACCOUNT_ID')
BW_VOICE_APPLICATION_ID = ENV.fetch('BW_VOICE_APPLICATION_ID')
BW_NUMBER = ENV.fetch('BW_NUMBER')
USER_NUMBER = ENV.fetch('USER_NUMBER')
BASE_CALLBACK_URL = ENV.fetch('BASE_CALLBACK_URL')
rescue
p 'Please set the environmental variables defined in the README'
exit(-1)
end
Bandwidth.configure do |config|
config.username = BW_USERNAME
config.password = BW_PASSWORD
end
calls_api_instance = Bandwidth::CallsApi.new
amd_config = Bandwidth::MachineDetectionConfiguration.new(
mode: Bandwidth::MachineDetectionModeEnum::SYNC,
detection_timeout: 15.0,
silence_timeout: 5.0,
speech_threshold: 5.0,
speech_end_threshold: 1.0,
callback_url: BASE_CALLBACK_URL + '/machineDetection',
callback_method: Bandwidth::CallbackMethodEnum::POST
)
call_body = Bandwidth::CreateCall.new(
application_id: BW_VOICE_APPLICATION_ID,
to: USER_NUMBER,
from: BW_NUMBER,
answer_url: BASE_CALLBACK_URL + '/answer',
machine_detection: amd_config
)
begin
result = calls_api_instance.create_call(BW_ACCOUNT_ID, call_body)
p result.call_id
rescue Bandwidth::ApiError => e
p e.code
end
import {
CallsApi,
Configuration,
CallbackMethodEnum,
MachineDetectionModeEnum
} from 'bandwidth-sdk';
const BW_USERNAME = process.env.BW_USERNAME;
const BW_PASSWORD = process.env.BW_PASSWORD;
const BW_ACCOUNT_ID = process.env.BW_ACCOUNT_ID;
const BW_VOICE_APPLICATION_ID = process.env.BW_VOICE_APPLICATION_ID;
const BW_NUMBER = process.env.BW_NUMBER;
const USER_NUMBER = process.env.USER_NUMBER;
const BASE_CALLBACK_URL = process.env.BASE_CALLBACK_URL;
const config = new Configuration({
BW_USERNAME,
BW_PASSWORD
});
const callsApi = new CallsApi(config);
const amdConfig = {
mode: MachineDetectionModeEnum.Sync,
detectionTimeout: 5.0,
silenceTimeout: 5.0,
speechThreshold: 5.0,
speechendThreshold: 5.0,
delayResult: true,
callbackMethod: CallbackMethodEnum.Post
};
const callBody = {
applicationId: BW_VOICE_APPLICATION_ID,
to: USER_NUMBER,
from: BW_NUMBER,
displayName: 'NodeJS SDK',
answerUrl: `${BASE_CALLBACK_URL}/callbacks/answer`,
answerMethod: CallbackMethodEnum.Post,
disconnectUrl: `${BASE_CALLBACK_URL}/callbacks/disconnect`,
disconnectMethod: CallbackMethodEnum.Get,
machineDetection: amdConfig,
callTimeout: 30.0,
callbackTimeout: 15.0
};
const { status, data } = await callsApi.createCall(BW_ACCOUNT_ID, callBody);
import os
import bandwidth
from pprint import pprint
configuration = bandwidth.Configuration(
username=os.environ["BW_USERNAME"],
password=os.environ["BW_PASSWORD"]
)
with bandwidth.ApiClient(configuration) as api_client:
api_instance = bandwidth.CallsApi(api_client)
account_id = os.environ["BW_ACCOUNT_ID"]
machine_detection_configuration = bandwidth.MachineDetectionConfiguration(
mode=bandwidth.MachineDetectionModeEnum.SYNC,
detection_timeout=15,
silence_timeout=5,
speech_threshold=5,
speech_end_threshold=1,
delay_result=True,
callback_url="http://example.com/machineDetectionCallback",
callback_method="POST"
)
create_call = bandwidth.CreateCall(
to=os.environ["USER_NUMBER"],
var_from=os.environ["BW_NUMBER"],
answer_url=os.environ["VOICE_CALLBACK_URL"],
application_id=os.environ["BW_VOICE_APPLICATION_ID"],
machine_detection=machine_detection_configuration
)
try:
api_response = api_instance.create_call(account_id, create_call)
print("The response of CallsApi->create_call:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling CallsApi->create_call: %s\n" % e)
require "vendor/autoload.php";
$BW_USERNAME = getenv("BW_USERNAME");
$BW_PASSWORD = getenv("BW_PASSWORD");
$BW_ACCOUNT_ID = getenv("BW_ACCOUNT_ID");
$BW_VOICE_APPLICATION_ID = getenv("BW_VOICE_APPLICATION_ID");
$BW_NUMBER = getenv("BW_NUMBER");
$USER_NUMBER = getenv("USER_NUMBER");
$VOICE_CALLBACK_URL = getenv("VOICE_CALLBACK_URL");
$config = new BandwidthLib\Configuration(
array(
'voiceBasicAuthUserName' => $BW_USERNAME,
'voiceBasicAuthPassword' => $BW_PASSWORD,
)
);
$client = new BandwidthLib\BandwidthClient($config);
$voiceClient = $client->getVoice()->getClient();
$machineDetection = new BandwidthLib\Voice\Models\MachineDetectionConfiguration();
$machineDetection->mode = BandwidthLib\Voice\Models\ModeEnum::SYNC;
$machineDetection->callbackMethod = "POST";
$machineDetection->detectionTimeout = 15.0;
$machineDetection->silenceTimeout = 5.0;
$machineDetection->speechThreshold = 5.0;
$machineDetection->speechEndThreshold = 1.0;
$machineDetection->delayResult = true;
$body = new BandwidthLib\Voice\Models\CreateCallRequest();
$body->from = $BW_NUMBER;
$body->to = $USER_NUMBER;
$body->answerUrl = $VOICE_CALLBACK_URL;
$body->applicationId = $BW_VOICE_APPLICATION_ID;
$body->machineDetection = $machineDetection;
#remember to add auth for your application if needed!
try {
$response = $voiceClient->createCall($BW_ACCOUNT_ID, $body);
print_r($response->getResult()->callId);
} catch (BandwidthLib\APIException $e) {
print_r($e->getResponseCode());
}
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: