benjamin-dean avatar image
benjamin-dean posted cameron736 commented

Subscribing to presence events of multiple extensions using RCSDK

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:

Once you have the prerequisites ready...

  1. Authenticate as the Admin user using the API Explorer, with these scopes: ReadAccounts, ReadPresence, ReadCallLog!/Authentication/oauth_token_post

  2. GET the list of all extensions within the account:!/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": "<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>;       }     }

  3. Using the record of extensions from the response in Step #2, populate the array property named "eventFilters" for the POST body request to!/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"    }  }

  4. 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                        
1 |3000

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

cameron736 avatar image cameron736 commented ·
Can't you use a tilda in place of extension in the eventFilter rather than explicitly specifying each extension?
0 Likes 0 ·
benjamin-dean avatar image benjamin-dean commented ·
No, because the tilda is only going to equal the currently logged in user, not necessarily the entire explicit list of multiple extensions.
0 Likes 0 ·
cameron736 avatar image cameron736 benjamin-dean commented ·
Ah, I see. Thanks for the fast response.
1 Like 1 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys



Mary-Community_Moderator contributed to this article benjamin-dean contributed to this article