Question

How to implement Webhook for Ringcentral app(platform Type Browser based) in java

  • 6 October 2020
  • 1 reply
  • 234 views

Hi, we need to use webHooks in our application. My RingCentral app platform type is browser based so it not supporting password flow. But to use webhooks it seems like password flow is mandatory as i go through in api reference.So can you please suggest how to use webhook for platform type browser based.

This is our application Type and permissions.

App Type - Web browser (Javascript)

Access - All RingCentral customers

Available Auth Flows

Auth Code(true)

Implicit(true)

Password(false)

Refresh token(true)


1 reply

Userlevel 1

Check out and combine these 2 dev guide examples:

  1. Authorization flow
  2. Webhooks

See the sample code below where I added the "/subscribe" case to handle webhook subscription.

case "/test":
  String api = request.getParameter("api");
  String result = "";
  switch (api) {
    case "extension":
      result = JSON.toJSONString(rc.restapi().account().extension().list(), SerializerFeature.PrettyFormat);
      break;
    case "extension-call-log":
      result = JSON.toJSONString(rc.restapi().account().extension().calllog().list(), SerializerFeature.PrettyFormat);
      break;
    case "account-call-log":
      result = JSON.toJSONString(rc.restapi().account().calllog().list(), SerializerFeature.PrettyFormat);
      break;
  }
  response.getWriter().println("<pre>" + result + "</pre>");
  break;
case "/subscribe":
  String result = ""; 
  var eventFilters = new String[]{
         "/restapi/v1.0/account/~/extension/~/message-store/instant?type=SMS"
         }
  CreateSubscriptionRequest createSubscriptionRequest = new CreateSubscriptionRequest()
      .eventFilters(eventFilters)
      .deliveryMode( new NotificationDeliveryModeRequest()
        .transportType("WebHook")
        .address(DELIVERY_ADDRESS)
      );
  var result = rc.restapi().subscription().post(createSubscriptionRequest);


Reply