question

Super Admin avatar image
Super Admin asked ·

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?
General Topic
1 |1000 characters needed characters left characters exceeded

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 ·
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 |1000 characters needed characters left characters exceeded

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

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 ·

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 ·
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 |1000 characters needed characters left characters exceeded

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

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 ·

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 |1000 characters needed characters left characters exceeded

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

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 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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