google-apigoogle-chatgoogle-api-javascript-client

Google Chat (Spaces) Add Member as Manager


I am attempting to add different users to a Google Space and set their roles as Members or Managers. When I try to set the role to ROLE_MANAGER, it always defaults to ROLE_MEMBER. In reading the reference and seeing that "role" is output only, this appears impossible currently.

However, when I view the documentation from Google APIs Node.js Client when I hover over the function , it does state that I can specify the role as part of RequestBody:

 // Request body metadata
    requestBody: {
      // request body parameters
      // {
      //   "createTime": "my_createTime",
      //   "member": {},
      //   "name": "my_name",
      //   "role": "my_role",
      //   "state": "my_state"
      // }
    },

An example of this is:

const res = await chat.spaces.members.create({
        parent: 'spaces/XXXXXXXXXXXXX',
        requestBody: {
            member: {
                name: member,
                type: 'HUMAN',
            },
            role: 'ROLE_MANAGER',
        },
    });
    console.log(res);

Does anyone know if there is another way to set the role to "ROLE_MANAGER" for a user being added to a Space?


Solution

  • No, there is no way to assign the role 'ROLE_MANAGER' when adding a user to the chat space at yet.

    As stated in the document you mentioned:

    Output only. User's role within a Chat space, which determines their permitted actions in the space.

    This revision clarifies the prohibition on assigning the 'ROLE_MANAGER' role.

    However, you have the option to request this feature from google chat API support.