question

akkarao b avatar image
akkarao b asked Phong Vu answered

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

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)

webhooks
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Phong Vu avatar image
Phong Vu answered

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);


1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys