RingCentral- A new era of fast messaging implementation

RingCentral SMS Functionality Experience

Hi folks, in this blog I'll share my experience with RingCentral for sending the sms via a java code. 

As a prerequisite, you must have your developer account created at developers.ringcentral.com

1. Login to the portal and go to apps section shown below

2. Now create an app by providing the details as suggested in the wizard. I've used java class to send the sms so password grant type has been selected automatically, you can choose yours based on your app/ requirement

3. You must select the 'App Permissions' to at 'Read Accounts' to facilitate SMS functionality


4. Get credentials

5. Set app permissions whatever applicable in your case-

6. Get all the access details of your app.

7. Pls try the OOTB feature via dev portal itself for sending the sms directly-


Next, We'll create a sample Gradle java project and will use the following sample code: 

build.gradle

plugins {

    id 'java-library'

}

dependencies {

    api 'org.apache.commons:commons-math3:3.6.1'

    implementation 'com.google.guava:guava:23.0'

    testImplementation 'junit:junit:4.12'

    

    compile 'com.ringcentral:ringcentral:1.4.0'

}

repositories {

    jcenter()

}


SendSMS.java

import java.io.IOException;
import com.ringcentral.*;
import com.ringcentral.definitions.*;

public class Send_SMS1 {
    static String RECIPIENT_NUMBER = "+125XXXX8203";

    static String RINGCENTRAL_CLIENTID = "XENglXXXXXXDKaXEQ";
    static String RINGCENTRAL_CLIENTSECRET = "ktxWLXXCT-SECRET";
    static String RINGCENTRAL_SERVER = "https://platform.devtest.ringcentral.com";

    static String RINGCENTRAL_USERNAME = "+13128589647";
    static String RINGCENTRAL_PASSWORD = "<YOUR_RINGCENTRAL_PASSWORD>";
    static String RINGCENTRAL_EXTENSION = "101";

    static RestClient restClient;
    public static void main(String[] args) {
        var obj = new Send_SMS1();
        try {
          restClient = new RestClient(RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, RINGCENTRAL_SERVER);
          restClient.authorize(RINGCENTRAL_USERNAME, RINGCENTRAL_EXTENSION, RINGCENTRAL_PASSWORD);
          obj.read_extension_phone_number();
        } catch (RestException | IOException e) {
          e.printStackTrace();
        }
    }
    public void read_extension_phone_number() throws RestException, IOException{
      var resp =  restClient.restapi().account().extension().phonenumber().get();
      OUTERMOST: for (var record : resp.records) {
          for(var feature : record.features)
        {
          if (feature.equalsIgnoreCase("SmsSender"))
          {
            send_sms(record.phoneNumber);
            break OUTERMOST;
          }
        }
      }
    }

    public void send_sms(String phoneNumber) throws RestException, IOException {
        CreateSMSMessage postParameters = new CreateSMSMessage();
        postParameters.from = new MessageStoreCallerInfoRequest().phoneNumber(phoneNumber);
        postParameters.to = new MessageStoreCallerInfoRequest[]{new MessageStoreCallerInfoRequest().phoneNumber(RECIPIENT_NUMBER)};
        postParameters.text = "Congratulations for your Apple MacBook Pro + iPad Mini + iPhone 12!";

        var response = restClient.restapi().account().extension().sms().post(postParameters);
        System.out.println("SMS sent. Message status: " + response.messageStatus);
    }
}

Now just run your java program and see the output in the console, it actually sends SMS immediately on the respective number. 



[NOTE] 
I have used a third-party app to get an international US number since SMS on an Indian number is not available in the free plan.










Comments

Popular posts from this blog

Oracle SOA Suite- Implementing Email Notification

Oracle SOA Suite 12c- PKIX path building failed & unable to find valid certification path to requested target

Migration of Oracle SOA Suite Composite from 11g to 12c