Skip to main content

Hey, guys.

I have just recently started working with Ringcentral platform and Ringcentral API in particular. The Developer Guide and API Reference are well written and contain a lot of helpful information.

The thing I'm missing though are some guides on how to cover specific workflows.

The task I have is to sync calls users made in Ringcentral to external CRM app.

I figured it would be good to use a webhooks for that matter.
I subscribe to Account Telephony Sessions Event for Disconnected calls only.

/restapi/v1.0/account/~/telephony/sessions?statusCode=Disconnected


As far as I can tell, there are about 3-4 "Disconnected" webhooks fires for every call.
So I need to filter those somehow to process only one that I really need.


By trial and error I found out that webhooks with "reason" ('body', 'parties', 0, 'status', 'reason') CallerInputRedirect and BlindTransfer can be ignored (?).
Maybe something else can be dropped?


Then I drop webhooks without "extensionId" ('body', 'parties', 0, 'extensionId').
Finally, I want to skip internal calls. Not sure what's the best way to do this, but right now here is the logic:


Internal inbound call: ('body', 'parties', 0, 'direction') == 'Inbound' && ('body', 'parties', 0, 'from', 'extensionId').present?
Outbound call: ('body', 'parties', 0, 'direction') == 'Outbound' && ('body', 'parties', 0, 'to', 'extensionId').present?

To get detailed information about a call is expensive API operation, so need to use as much information as possible from the webhook data.

If webhook passes all these checks, I call call-log API to get detailed information about the call, like duration, start time, recording etc. and create corresponding record in CRM.

restapi/v1.0/account/~/extension/#{extension_id}/call-log?telephonySessionId=telephony_session_id


So the question is does all the precaution checks I use makes sense or can I tweak/simplify it in any way? Or maybe something is missing in my flow.
And in general, is webhook approach is the right solution here or maybe Sync Company Call Log would be more appropriate.
Any advice is greatly appreciated.

If you just need to export/sync the call log data from your RingCentral account to your own database, you can use the read account call log API or the call log sync API to do so. Please read these articles to learn more and come back if you have further questions.

https://medium.com/ringcentral-developers/visualize-your-business-communications-history-2c81f85c324a

https://medium.com/ringcentral-developers/sync-ringcentral-call-log-into-google-sheets-with-google-apps-script-daacc9a73b72

If you really want to create your own call log in real time using the raw data, you can use the telephony session events notifications and parse the event payload. However, this will be much more complicated than the other option. Please read these articles to learn more about the telephony session events

https://medium.com/ringcentral-developers/ringcentral-telephony-session-events-notifications-98b3f8d29745

https://medium.com/ringcentral-developers/building-a-real-time-call-report-app-3eee247a141d



Reply