REST API Ringout results

  • 1
  • Question
  • Updated 2 years ago
Hi

I've implemented ringout using the REST API and its working as expected. I have also setup a webhook notification, which is also working.


I'd like to know if its possible to tell if the recipient (the to number) never answered or the call went to voice mail?

I don't see anything that indicates this in the call log or in the notification payload


Thanks
Photo of Janielle

Janielle

  • 530 Points 500 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Benjamin Dean

Benjamin Dean

  • 8,602 Points 5k badge 2x thumb
Have you tried setting the `view=Detailed` query parameter for your GET request to /call-log to view the information about each leg of a call and the callStatus? https://developers.ringcentral.com/api-docs/latest/index.html#!#RefExtensionCallLog.html

Another option would be to create a Push Notification (Subscription or Webhook) event consumer to be notified of presence events for extensions you wish to monitor. https://developers.ringcentral.com/api-docs/latest/index.html#!#RefNotifications.html
Photo of Janielle

Janielle

  • 530 Points 500 badge 2x thumb
Yes, I have viewed the call logs with view=Detailed and I see nothing that indicates that the recipient didn't answer (or it went to voicemail)

As mentioned in my question I have webhook for notifications and there is nothing useful there either.
Photo of Benjamin Dean

Benjamin Dean

  • 8,602 Points 5k badge 2x thumb
Could you provide the code you're using to create the webhooks and the filters you're using please? Also, if you could provide some example of the webhook events you're receiving, this might help to drill down into what is blocking you from being able to achieve your goal.
Photo of Janielle

Janielle

  • 530 Points 500 badge 2x thumb
Hi,

Sorry for only getting back to you now.

This is the JSON I POST to the subscription end point,
{
"eventFilters": [
"/restapi/v1.0/account/~/extension/~/presence?detailedTelephonyState=true&sipData=true",
"/restapi/v1.0/account/~/extension/~/presence/line/presence"
],
"deliveryMode": {
"transportType": "WebHook",
"address": "http://ringcentral.somedomain.io/v1/rpc/call/webhook"
}
}
This is for a ringout type call, all I can tell is that the calling side answered, there is no mention of the other party's status etc.

Here is what I see in the webhook event log.

{'json.data': {'body': {'activeCalls': [{'id': '', 'sessionId': '14424925004', 'from': '+34343434', 'telephonyStatus': 'Ringing', 'to': '+121212', 'sipData': {'localUri': 'sip:+34343434@ringcentral.com', 'remoteUri': 'sip:+121212@ringcentral.com'}, 'direction': 'Outbound'}], 'pickUpCallsOnHold': False, 'allowSeeMyPresence': True, 'sequence': 23753, 'telephonyStatus': 'Ringing', 'ringOnMonitoredCall': False, 'extensionId': 136908004, 'dndStatus': 'TakeAllCalls', 'userStatus': 'Available', 'presenceStatus': 'Available'}, 'uuid': '043d2818-7175-4dab-84b1-8aef485df15b', 'timestamp': '2016-08-30T15:02:39.437Z', 'subscriptionId': 'd424d24c-4104-4223-ad60-da3ebe40b1cf', 'event': '/restapi/v1.0/account/136908004/extension/136908004/presence?detailedTelephonyState=true&sipData=true'}}

/* Caller Answers his phone */

{'json.data': {'body': {'activeCalls': [{'id': 'da47a24af2f44ef4b12dbc0cd0abcea6', 'sessionId': '14424925004', 'from': '+34343434', 'telephonyStatus': 'CallConnected', 'to': '+121212', 'sipData': {'remoteUri': 'sip:+121212@ringcentral.com', 'fromTag': '10.28.20.109-5070-7d73312c2f8841', 'toTag': 'gK029fd65d', 'localUri': 'sip:+34343434@ringcentral.com'}, 'direction': 'Outbound'}], 'pickUpCallsOnHold': False, 'allowSeeMyPresence': True, 'sequence': 23755, 'telephonyStatus': 'CallConnected', 'ringOnMonitoredCall': False, 'extensionId': 136908004, 'dndStatus': 'TakeAllCalls', 'userStatus': 'Available', 'presenceStatus': 'Busy'}, 'uuid': '5ace2bdf-690a-4f44-bae3-fd98c0e075ce', 'timestamp': '2016-08-30T15:02:49.089Z', 'subscriptionId': 'd424d24c-4104-4223-ad60-da3ebe40b1cf', 'event': '/restapi/v1.0/account/136908004/extension/136908004/presence?detailedTelephonyState=true&sipData=true'}}

/* Call Ends */

{'json.data': {'body': {'userStatus': 'Available', 'pickUpCallsOnHold': False, 'telephonyStatus': 'NoCall', 'ringOnMonitoredCall': False, 'extensionId': 136908004, 'dndStatus': 'TakeAllCalls', 'allowSeeMyPresence': True, 'presenceStatus': 'Available'}, 'uuid': 'f663e0a4-b8ef-4dcb-8c0a-0e266cc5eae6', 'timestamp': '2016-08-30T15:03:35.347Z', 'subscriptionId': 'd424d24c-4104-4223-ad60-da3ebe40b1cf', 'event': '/restapi/v1.0/account/136908004/extension/136908004/presence?detailedTelephonyState=true&sipData=true'}}
(Edited)
Photo of Benjamin Dean

Benjamin Dean

  • 8,602 Points 5k badge 2x thumb
The data you've provided has a `telephonyStatus` property which indicates what happens with a call.

Have you tried generating the two use cases you've provided in your original question (Missed Call, and VoiceMail) to see what the result is in the `telephonyStatus` property?
Photo of Janielle

Janielle

  • 530 Points 500 badge 2x thumb
yes I have, it says the same thing for both:
'telephonyStatus': 'CallConnected'
Photo of Benjamin Dean

Benjamin Dean

  • 8,602 Points 5k badge 2x thumb
Could you provide the full event stream (as you did earlier) for:

1. A missed call
2. A voicemail call
Photo of Janielle

Janielle

  • 530 Points 500 badge 2x thumb
Here you go.

Missed Call

{'json.data': {'timestamp': '2016-08-31T15:42:21.555Z', 'event': '/restapi/v1.0/account/136908004/extension/136908004/presence?detailedTelephonyState=true&sipData=true', 'subscriptionId': 'e36f3168-0c5e-4ff7-b343-b643d80fd1cd', 'uuid': '6effe768-758c-407f-a7ef-0ea70bcbf2fa', 'body': {'telephonyStatus': 'Ringing', 'allowSeeMyPresence': True, 'dndStatus': 'TakeAllCalls', 'activeCalls': [{'telephonyStatus': 'Ringing', 'sipData': {'localUri': 'sip:+2222222@ringcentral.com', 'remoteUri': 'sip:+1111111@ringcentral.com'}, 'direction': 'Outbound', 'id': '', 'sessionId': '14430984004', 'to': '+1111111', 'from': '+2222222'}], 'sequence': 27266, 'extensionId': 136908004, 'pickUpCallsOnHold': False, 'userStatus': 'Available', 'presenceStatus': 'Available', 'ringOnMonitoredCall': False}}}

{'json.data': {'timestamp': '2016-08-31T15:42:31.644Z', 'event': '/restapi/v1.0/account/136908004/extension/136908004/presence?detailedTelephonyState=true&sipData=true', 'subscriptionId': 'e36f3168-0c5e-4ff7-b343-b643d80fd1cd', 'uuid': 'b32ce8c8-35f1-419c-8740-73819912635f', 'body': {'telephonyStatus': 'CallConnected', 'allowSeeMyPresence': True, 'dndStatus': 'TakeAllCalls', 'activeCalls': [{'telephonyStatus': 'CallConnected', 'sipData': {'localUri': 'sip:+2222222@ringcentral.com', 'fromTag': '10.28.20.109-5070-5bdc1b99d6c447', 'remoteUri': 'sip:+1111111@ringcentral.com', 'toTag': 'gK02f952af'}, 'direction': 'Outbound', 'id': '89acdd571ee642d0943324250e00d3b4', 'sessionId': '14430984004', 'to': '+1111111', 'from': '+2222222'}], 'sequence': 27268, 'extensionId': 136908004, 'pickUpCallsOnHold': False, 'userStatus': 'Available', 'presenceStatus': 'Busy', 'ringOnMonitoredCall': False}}} {'json.data': {'timestamp': '2016-08-31T15:42:49.205Z', 'event': '/restapi/v1.0/account/136908004/extension/136908004/presence?detailedTelephonyState=true&sipData=true', 'subscriptionId': 'e36f3168-0c5e-4ff7-b343-b643d80fd1cd', 'uuid': '196b281a-51ca-42bd-8359-da130cb249b0', 'body': {'telephonyStatus': 'NoCall', 'dndStatus': 'TakeAllCalls', 'allowSeeMyPresence': True, 'userStatus': 'Available', 'pickUpCallsOnHold': False, 'extensionId': 136908004, 'presenceStatus': 'Available', 'ringOnMonitoredCall': False}}}

Voicemail

{'json.data': {'timestamp': '2016-08-31T15:40:29.627Z', 'event': '/restapi/v1.0/account/136908004/extension/136908004/presence?detailedTelephonyState=true&sipData=true', 'subscriptionId': 'e36f3168-0c5e-4ff7-b343-b643d80fd1cd', 'uuid': 'c3c98916-5c16-4a83-b757-54d592deb1fa', 'body': {'telephonyStatus': 'Ringing', 'allowSeeMyPresence': True, 'dndStatus': 'TakeAllCalls', 'activeCalls': [{'telephonyStatus': 'Ringing', 'sipData': {'localUri': 'sip:+2222222@ringcentral.com', 'remoteUri': 'sip:+11111111@ringcentral.com'}, 'direction': 'Outbound', 'id': '', 'sessionId': '14430974004', 'to': '+11111111', 'from': '+2222222'}], 'sequence': 27263, 'extensionId': 136908004, 'pickUpCallsOnHold': False, 'userStatus': 'Available', 'presenceStatus': 'Available', 'ringOnMonitoredCall': False}}}

{'json.data': {'timestamp': '2016-08-31T15:40:42.548Z', 'event': '/restapi/v1.0/account/136908004/extension/136908004/presence?detailedTelephonyState=true&sipData=true', 'subscriptionId': 'e36f3168-0c5e-4ff7-b343-b643d80fd1cd', 'uuid': '3f66c368-b673-4455-8250-b49f0a5e0325', 'body': {'telephonyStatus': 'CallConnected', 'allowSeeMyPresence': True, 'dndStatus': 'TakeAllCalls', 'activeCalls': [{'telephonyStatus': 'CallConnected', 'sipData': {'localUri': 'sip:+2222222@ringcentral.com', 'fromTag': '10.28.20.110-5070-aaf99dee0c7d4a', 'remoteUri': 'sip:+11111111@ringcentral.com', 'toTag': 'gK02f8cf47'}, 'direction': 'Outbound', 'id': 'c4833d50e5cf4d50b93a2da4a8d79ae1', 'sessionId': '14430974004', 'to': '+11111111', 'from': '+2222222'}], 'sequence': 27264, 'extensionId': 136908004, 'pickUpCallsOnHold': False, 'userStatus': 'Available', 'presenceStatus': 'Busy', 'ringOnMonitoredCall': False}}}

{'json.data': {'timestamp': '2016-08-31T15:41:11.423Z', 'event': '/restapi/v1.0/account/136908004/extension/136908004/presence?detailedTelephonyState=true&sipData=true', 'subscriptionId': 'e36f3168-0c5e-4ff7-b343-b643d80fd1cd', 'uuid': '352d3619-5416-4f0d-b124-e781ed4d7528', 'body': {'telephonyStatus': 'NoCall', 'dndStatus': 'TakeAllCalls', 'allowSeeMyPresence': True, 'userStatus': 'Available', 'pickUpCallsOnHold': False, 'extensionId': 136908004, 'presenceStatus': 'Available', 'ringOnMonitoredCall': False}}}
Photo of Benjamin Dean

Benjamin Dean

  • 8,602 Points 5k badge 2x thumb
So your presence events for both types have a "NoCall" telephonyStatus at the end.

When your application sees that NoCall event (which means the end of a call), then you should capture the `sessionId` for that call, and then you can do a lookup in the Call Log API for that extension and filter by sessionId (Call Log Record) === sessionId (presenceEvent). Then you can use the `result` property of the Call Log record to provide you the information you require.

Does this answer your question?
Photo of Janielle

Janielle

  • 530 Points 500 badge 2x thumb
Hi Benjamin,

Thanks for that. I did as you said, I queried the call log for the two session id's above (the one for the voice mail and the one for the missed call) and for both it returns:

"result": "Call connected",
Photo of Benjamin Dean

Benjamin Dean

  • 8,602 Points 5k badge 2x thumb
You'll need to query the call log data from the other side of the call (the recipient side, which would be one of your RingCentral users).

You can do this in one of two ways:

1. Call Logs by Extension (as Recipient)
-or-
2. Call Logs as Admin User (and filter by Extension.id + session.id)

The reason for this is because every call has at least two parties: caller (person placing the call) and callee (recipient of the call being placed).

If you are fetching the call logs from the callers side (as your initial data indicated with the `direction` property set to "Outbound"), then yes, you will only ever see "CallConnected" if the call was actually connected.

You'll need to GET the call-log data for the "callee". Then you should see the different statuses which will indicate either `Missed` or `VoiceMail`.
Photo of Janielle

Janielle

  • 530 Points 500 badge 2x thumb
ok, I understand, but that would only work if the callee is a ring central user. In our case we are using the Ringout feature and the callee could be anyone. 
Photo of Benjamin Dean

Benjamin Dean

  • 8,602 Points 5k badge 2x thumb
To try and determine this for outbound calls, you'll have to mix and match your programming logic between call log and message store data.

You might ask how to do this in Stackoverflow (use the `ringcentral` tag), since there are a lot more developers there who love to answer questions (and we're moving towards that system for technical questions anyway). You should reference this conversation in the question on SO.