Contents

Ring Central - Making A Voice Call With Java

Contents

In my last post, I showed you how to send an SMS message with Java and Ring Central. In this post, I’ll show you how to make a voice call. If you get stuck, refer to the developer portal docs, but it’s pretty simple.

As always, first include the dependency:

compile 'com.ringcentral:ringcentral:1.0.0-beta10'

Next, in your class, set some variables:

static String RECIPIENT_NUMBER = "<ENTER PHONE NUMBER>";

static String RINGCENTRAL_CLIENTID = "<ENTER CLIENT ID>";
static String RINGCENTRAL_CLIENTSECRET = "<ENTER CLIENT SECRET>";
static String RINGCENTRAL_SERVER = "https://platform.devtest.ringcentral.com";

static String RINGCENTRAL_USERNAME = "<YOUR ACCOUNT PHONE NUMBER>";
static String RINGCENTRAL_PASSWORD = "<YOUR ACCOUNT PASSWORD>";
static String RINGCENTRAL_EXTENSION = "<YOUR EXTENSION, PROBABLY '101'>";

static RestClient restClient;

Create an instance of the client:

try {
  restClient = new RestClient(RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, RINGCENTRAL_SERVER);
  restClient.authorize(RINGCENTRAL_USERNAME, RINGCENTRAL_EXTENSION, RINGCENTRAL_PASSWORD);
} 
catch (RestException | IOException e) {
  e.printStackTrace();
}

Now you’re ready to make a call:

MakeRingOutRequest requestBody = new MakeRingOutRequest();
requestBody.from(new MakeRingOutCallerInfoRequestFrom().phoneNumber(RINGCENTRAL_USERNAME));
requestBody.to(new MakeRingOutCallerInfoRequestTo().phoneNumber(RECIPIENT_NUMBER));
requestBody.playPrompt = false;

var response = restClient.restapi().account().extension().ringout().post(requestBody);
System.out.println("Call Placed. Call status: " + response.status.callStatus);

And that’s all it takes to make a voice call with Ring Central and Java.

Image by kareni from Pixabay