Solved

DND from Desk phones or Can Admins set this for users

  • 11 October 2019
  • 1 reply
  • 1496 views

1) I want to be able to have Users in my Call/Hunt group have the ability to set themselves to DND from there deskphone with out having to also have the Softphone installed.

2) Can an admin go in and set users that forget to go in to DND for them?

icon

Best answer by Phong1426275020 11 October 2019, 18:31

View original

1 reply

Userlevel 1

Yes, you can write an app, login with the super admin user, then you can read all users' presence status and set their status as well. Here is some code snippet in Node JS.

var SDK = require('ringcentral')

RINGCENTRAL_CLIENTID = 'your app client id'
RINGCENTRAL_CLIENTSECRET = 'your app client secret'
RINGCENTRAL_SERVER = 'https://platform.devtest.ringcentral.com'

RINGCENTRAL_USERNAME = 'super admin user name'
RINGCENTRAL_PASSWORD = 'password'
RINGCENTRAL_EXTENSION = '101'

var rcsdk = new SDK({
      server: RINGCENTRAL_SERVER,
      appKey: RINGCENTRAL_CLIENTID,
      appSecret: RINGCENTRAL_CLIENTSECRET
  });
var platform = rcsdk.platform();
platform.login({
      username: RINGCENTRAL_USERNAME,
      password: RINGCENTRAL_PASSWORD,
      extension: RINGCENTRAL_EXTENSION
      })
      .then(function(resp) {
          get_users_presence()
      });

function get_users_presence(){
    platform.get('/account/~/presence')
        .then(function (resp) {
          var jsonObj = resp.json()
          for (var record of jsonObj.records){
            console.log("====")
            console.log(JSON.stringify(record))
            // check the extension you want to change its presence status
            if (record.extension.id == "244609004"){
              set_user_presence(record.extension.id)
              break
            }
          }
        })
        .catch(function(e){
          console.log(e.message)
        });
}

function set_user_presence(extId){
    var endpoint = '/account/~/extension/'+ extId +'/presence'
    platform.put(endpoint, {
              dndStatus: "DoNotAcceptAnyCalls"
        })
        .then(function (resp) {
          var jsonObj = resp.json()
          console.log(resp.text())
        })
        .catch(function(e){
          console.log(e.message)
        });
}


Reply