This article describes the basic process of how to subscribe to the presence events of multiple extensions within a single account using the RingCentral API.
A couple of example use cases for this are:
- Call Center Administrative Dashboard (beta)
- Logging of caller id(s) into a CRM or other authoritative database
You will need the following prerequisites to continue with this article:
- An active RingCentral account
- Registered as a RingCentral Developer
- Access to the RingCentral API Explorer
- Ability to authenticate as an Admin user on the RingCentral account
- Have more than one User created in the system (to test this solution)
- An application running with the js-rcsdk installed and instantiated in your app
Once you have the prerequisites ready...
- Authenticate as the Admin user using the API Explorer, with these scopes: ReadAccounts, ReadPresence, ReadCallLog
http://ringcentral.github.io/api-explorer/#!/Authentication/oauth_token_post - GET the list of all extensions within the account:
http://ringcentral.github.io/api-explorer/#!/Account_and_Extension_Information/v1_0_account__account...
This will return a JSON response which contains a property named "records" which is an array. Each child node of that array is an extension object from RingCentral.
Here is an example extension object:L{ "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/<ACCOUNT_ID>/extension/<EXTENSION_ID>";, "id": <EXTENSION_ID>, "extensionNumber": "102", "contact": { "firstName": "Dummy", "lastName": "User", "email": "<USER_EMAIL>" }, "name": "Dummy User", "type": "User", "status": "Activated", "permissions": { "admin": { "enabled": false }, "internationalCalling": { "enabled": true } }, "profileImage": { "uri": "<PROFILE_IMAGE_URI>; } }
- Using the record of extensions from the response in Step #2, populate the array property named "eventFilters" for the POST body request to http://ringcentral.github.io/api-explorer/#!/Notifications/v1_0_subscription_post.
You'll want to add a new array child node for each extension. If we had three extension records returned: 101 (, 102, 103 (each with a unique ID), we would want to include a new array item as follows:{ "eventFilters": [ "/restapi/v1.0/account/~/extension/<101_ID>/presence", "/restapi/v1.0/account/~/extension/<102_ID>/presence", "/restapi/v1.0/account/~/extension/<103_ID>/presence", "/restapi/v1.0/account/~/extension/~/message-store" ], "deliveryMode": { "transportType": "PubNub", "encryption": "false" } }
- We'll use the response data we receive from defining this new subscription to establish a new PubNub channel. Here is an example of the response from /restapi/v1.0/subscription:
{ "id": "<SUBSCRIPTION_ID>", "creationTime": "2015-10-02T00:03:38.816Z", "status": "Active", "uri": " rest api