question

Super Admin avatar image
Super Admin asked Phong Vu commented

How to Query for Ring Out Call Duration

I have a requirement to record the details of calls initiated by Ring Out upon completion of the call. I'm successfully polling the Ring Out Status until the call is finished, but I can't find a way to then query for the User Call Record for the completed Ring Out. Is there a way to get the Session Id for a Ring Out call which can be used to retrieve the User Call Record and/or query for a User Call Record using a Ring Out Id? Better yet, can I create a subscription which will notify my service when a Ring Out call is completed?

sdk
1 |3000

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

Phong Vu avatar image
Phong Vu answered Phong Vu commented
Hi Dan,

Don't poll! Use the push notifications to subscribe for the detailed extension presence event. Check the developer guide at the "Notifications and Events" section for example code in different languages. From the notification payload, you can detect when a call is ringing, connected and hangup etc. You can use the sessionId to read the record from the call log later to get more details of that call. Unfortunately, the notification payload does not contain the call type so if you are interested at only "RingOut" call, you will have to check it from the call log record.
2 comments
1 |3000

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

Super Admin avatar image Super Admin commented ·

So a problem I'm seeing with this approach is that the Get User Call Log Records endpoint doesn't return the call log record for a session until well after the call actually completes, so when my subscription event handler fires there aren't yet call log records. If I put a 30 second sleep in I'm able to pull the record but that's not an acceptable solution. Am I missing something?

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ Super Admin commented ·

That's correct. Call log is created only about 20 secs after a call was terminated. If you want to get call information (similar to call log record) during a call, you can use the users active-calls endpoint, parse the response and match the sessionId to identify a call you detected from your subscription.

0 Likes 0 ·
Super Admin avatar image
Super Admin answered Super Admin commented
Thanks for the quick reply! I tried following your suggestion but the subscription callback is never firing. I'm implementing this in Java so the examples are limited. Is there anything obvious I'm doing wrong?
 private void subscribeToPhoneEvents(String extensionId) {     if(extensionSubscriptions.containsKey(extensionId)) {   return;  }  String[] eventFilters = new String[]  {   String.format("/restapi/v1.0/account/%s/extension/%s/presence?detailedTelephonyState=true", ringCentralAccount, extensionId)  };  Consumer<String> callback = payload -> {    DetailedPresenceNotification notification = JSON.parseObject( payload, DetailedPresenceNotification.class);   DetailedPresenceEvent event = notification.body;   if(event.telephonyStatus.equals("NoCall") && event.terminationType.equals("final")){    for(DetailedPresenceEvent_ActiveCallInfo callInfo: event.activeCalls) {     // Record Phone call details    }   }  };  RestClient restClient = new RestClient(ringCentralClientId, ringCentralClientSecret, ringCentralServer);  try {   restClient.authorize(ringCentralAccount, extensionId, ringCentralPassword);   Subscription subscription = restClient.subscription(eventFilters, callback);   subscription.subscribe();   extensionSubscriptions.put(extensionId, subscription);  } catch (IOException | RestException e) {   LOGGER.error(e.getMessage(),e);  } } 
1 comment
1 |3000

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

Super Admin avatar image Super Admin commented ·
Also, is there a way for me to get notified when a fax was sent successfully?
0 Likes 0 ·
Super Admin avatar image
Super Admin answered Phong Vu commented

I believe my subscription wasn't getting triggered because I hadn't given the app enough permissions. I'm successfully receiving notifications for phone calls, how can I receive a notification when a fax is successfully sent? I see fax records in the user's call log history but I'm not receiving a presence event when the fax is successfully transmitted.

1 comment
1 |3000

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

Phong Vu avatar image Phong Vu ♦♦ commented ·

Unfortunately, there is no notification event for Fax delivery. There might be a workaround solution using the message-store event. But that just give you a generic event when something happens to the message store, including when a Fax status is updated. However, it does not tell you exactly what was changed so you can only use it as an event trigger then poll the message store and look for the fax and its delivery status.

0 Likes 0 ·

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