question

Tyler Kocheff avatar image
Tyler Kocheff asked ·

Get User Groups for a Group Manager

Is there an API to pull in extensions only that a manager has authorization over? This is in regards to User Groups (Users > User Groups in the Admin Portal) I'm looking to pull in a Group Manager's group and then display all the extensions in the group to allow viewing and modifying their DND status.

I had incorrectly assumed that when pulling the list of extensions, that a manager would only see the users' they manage, but it winds up pulling all extensions from our 1000's of users. I don't see any API relating to User Groups.

group manageruser group
1 |1000 characters needed characters left characters exceeded

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

1 Answer

· Write an Answer
Phong Vu avatar image
Phong Vu answered ·

You are right about a User group's purpose. But any user/extension can see other's user/extension presence status. So does the group manager! That's why when you send a GET request to "account/~/presence", you will see the entire company's user presence status.

The privilege of a group manager is to update/modify a presence status of its group members without the need of being a super admin.

So in your case, you have to keep track of a list of a group's members, then let the group manager to read only those members and modify their presence status as you need. You can do something like this in Node JS:

var members = ["120", "121", "122"]
function read_user_presence(){
  platform.get('/account/~/presence', {
          sipData: true
      })
      .then(function (resp) {
        var jsonObj = resp.json()
        for (var record of resp.json().records){
          const member = (element) => element === record.extension.extensionNumber;
            if (members.some(member)){
              console.log(JSON.stringify(record))
              console.log("=======")
              // check a member's status then modify it accordingly
              update_user_presence(record.extension.id)
              }
         }
      });
}

function update_user_presence(id){
  platform.put('/account/~/extension/' + id + '/presence', {
          dndStatus: "DoNotAcceptAnyCalls"
      })
      .then(function (resp) {
        var jsonObj = resp.json()
        console.log(jsonObj)
      });
}


1 |1000 characters needed characters left characters exceeded

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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