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.