question

tina1256 avatar image
tina1256 asked benjamin-dean commented

Read SMS Message On Another Account

I'm developing a periodic task that will track specific SMS conversations on Ring Central, parse replies, and perform some updates to our database. Is there a way to read SMS messages from multiple accounts from one logged in account (i.e. can I use administrator credentials to read messages for all of our employees?).

sms and text messaging
1 |3000

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

1 Answer

benjamin-dean avatar image
benjamin-dean answered benjamin-dean commented
During a session where you have authenticated as a user with Administrative permissions for the account, you can currently only fetch the call-log data across all user extensions, but not the message-store (which is where the historical SMS data resides).

But that doesn't mean it cannot be done...

If you're using the JS SDK in Node.js, here is a way you could do that, let me know if this helps you workaround this inconvenience:


    var smsData;
    // Initialize the sdk
    var sdk= new RC({
        server: process.env.RC_API_BASE_URL,
        appKey: process.env.RC_APP_KEY,
        appSecret: process.env.RC_APP_SECRET
    });
    // Bootstrap Platform and Subscription
    var platform = sdk.platform();
    login();
    // Login to the RingCentral Platform
    function login() {
        return platform.login({
                username: process.env.RC_USERNAME,
                password: process.env.RC_PASSWORD,
                extension: process.env.RC_EXTENSION
            })  
            .then(init)
            .catch(function(e){
                console.log("Login Error into the RingCentral Platform :", e); 
                throw e;
            }); 
    }   
    /*  
        Obtain list of extensions after Login success
     */
    function init(loginData) {
        var extensions = []; 
        var page = 1;
        function getExtensionsPage() {
            return platform
                .get('/account/~/extensions', {
                    page: page,
                    perPage: process.env.DEVICES_PER_PAGE                                             //REDUCE NUMBER TO SPEED BOOTSTRAPPING
                })  
                .then(function(response) {
                    var data = response.json();
                    extensions = extensions.concat(data.records);
                    if (data.navigation.nextPage) {
                        page++;
                        return getExtensionsPage();                                                     // this will be chained
                    } else {
                        return extensions;                                                              // this is the finally resolved thing
                    }
                })
                .then(getAllExtensionSMS);
        }
        /*
                Loop until you capture all extensions
         */
        return getExtensionsPage()
            .then(function(extensinos) {
                return extensions;
            })
            .catch(function(e) {
                console.error("Error: getDevicesPage(): " + e);
                throw e;
             });
}
                                    
// Iterate to grab each extension's message-store?messageType=SMS
function getAllExtensionSMS(extensions) {
    return Promise.all(extensions.map(function(ext) {
        return platform
            .get('/account/~/extension/' + ext.id + '/message-store?messageType=SMS')
            .then(function(extensionSmsData) {
                smsData.concat(extensionSmsData.records);
            })
            .catch(function(e) {
                console.error(e);
                throw e;
            });
    })).catch(function(e) {
        console.error('Error with one of the promises to get SMS data', e);
        throw e;
    });
}
4 comments
1 |3000

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

tina1256 avatar image tina1256 commented ·
We're currently using the Python client, I tried to implement the equivalent of the script above, but it appears that '/account/~/extensions' is not a supported endpoint (I'm getting  an Invalid URI error). Does this mean this functionality is only supported for Node clients?
0 Likes 0 ·
benjamin-dean avatar image benjamin-dean commented ·
No, this is an API route (and our API is a modern, RESTful interface).

Here is the Extension resource on our API explorer:  https://developers.ringcentral.com/api-explorer/latest/index.html#/!/Extension/listExtensions

Additionally, you could use the RingCentral Python SDK available on Githubhttps://github.com/ringcentral/ringcentral-python You would need to re-write the code above in Python, but it should provide you with a little more direction on how to solve your use case.
0 Likes 0 ·
tina1256 avatar image tina1256 commented ·
The URL is spelled wrong in your example (it says '/account/~/extensions' instead of '../extension'). That makes sense, thanks for the quick reply. It appears that our app does not have sufficient permissions to access that endpoint anyways so we'll go with our own workaround.
0 Likes 0 ·
benjamin-dean avatar image benjamin-dean commented ·
My bad, fat-finger error.

You should be able to go into your Sandbox account's online portal: https://service.devtest.ringcentral.com as an admin and enable SMS for an extension (the extension will also need to be enabled and activated).

If you can send SMS from the softphone in sandbox mode for the user you're testing with via the API, then it should work (and there could be something else going on).

Let me know what you find out.
0 Likes 0 ·

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