Question

Read SMS Message On Another Account

  • 17 March 2016
  • 1 reply
  • 1079 views

  • Anonymous
  • 0 replies

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?).


1 reply

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;
    });
}

Reply