I'm trying to create an IVR Phone tree through REST API in Salesforce (Twilio API). The problem is that I can't catch any other callback status except 'completed'.
If the call was cancelled or there was no response on this call, Twilio sends a call response with 'completed' status anyway.
Moreover, a customer gets a voicemail with a recorded 'welcome' message and first phone tree question after an unsuccessful call attempt.
There is a code sample of how calls are created :
TwilioRestClient client = new TwilioRestClient(TwilioSID, TwilioToken);
Map<String,String> params = new Map<String, String>();
String webURL = webServerURL;
params.put('To', phone);
params.put('From', phoneFrom);
params.put('Url', webURL);
params.put('Method', 'GET');
params.put('FallbackUrl', webURL);
params.put('FallbackMethod', 'GET');
params.put('StatusCallback', webURL);
if (!System.Test.isRunningTest()) {
try {
TwilioCall call = client.getAccount().getCalls().create(params);
} catch(Exception ex) {
}
}
In addition, I was trying to add 'StatusCallbackEvent' parameter (link to Twilio documentation - https://www.twilio.com/docs/voice/twiml#callstatus-values) :
params.put('StatusCallbackEvent', 'busy canceled completed failed no-answer');
// and other optiions like :
// params.put('StatusCallbackEvent', 'busy');
// params.put('StatusCallbackEvent', 'canceled');
// params.put('StatusCallbackEvent', 'completed');
// params.put('StatusCallbackEvent', 'failed');
// params.put('StatusCallbackEvent', 'no-answer');
But there was no any difference in a callback status after failed calls.
How should I make calls to get Twilio call responses with all finalized statuses ('busy', 'failed', 'no-answer', etc ...) ?