In the next sample code, Twilio puts in conversation OPERATOR_PHONE_NUMBER to CLIENT_PHONE_NUMBER, and records the call.
But I don't know what should be the code to control some things, one or both of the phones...:
does not exist.
exists but communicates.
exists, does not communicate but does not pick up.
exists, does not communicate, picks up and the conversation takes place.
import com.twilio.Twilio; import com.twilio.rest.api.v2010.account.Call; import com.twilio.rest.api.v2010.account.CallCreator; import com.twilio.type.PhoneNumber; import com.twilio.type.Twiml; public class SimpleCallWithRecording2 { private static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; private static final String AUTH_TOKEN = "9ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"; private static final String ASSIGNED_PHONE_NUMBER = "+15999999999999"; //Must be verified numbers in trial account private static final String OPERATOR_PHONE_NUMBER = "+34888888888"; private static final String CLIENT_PHONE_NUMBER = "+34777777777"; public static void main(String[] args) throws Exception { Twilio.init(ACCOUNT_SID, AUTH_TOKEN); PhoneNumber to = new PhoneNumber(OPERATOR_PHONE_NUMBER); PhoneNumber from = new PhoneNumber(ASSIGNED_PHONE_NUMBER); Twiml twiml = new Twiml( "<?xml version=\"1.0\" encoding=\"UTF-8\"?> " + "<Response> " + " <Say voice=\"woman\">This is said by a robotic woman</Say> " + " <Dial> " + " <Number> " + CLIENT_PHONE_NUMBER + "</Number> " + " </Dial> " + "</Response> " ); CallCreator callCreator = Call.creator(to, from, twiml); callCreator.setRecord(true); Call call = callCreator.create(); System.out.println(call); }
}
In the doc I see something could be done with callCreator.setStatusCallback(URI.create("https://www.myapp.com/events"))
, and some clasification of events: "initiated", "ringing", "answered", "completed". BUT I havent find the code "on the other side", I mean in https://www.myapp.com/events extreme ¿?