How to manage Teams meeting role

In this article, you learn how users that joined Teams meetings or Room can learn the currently assigned role and manage role change.

Prerequisites

Join Teams meeting

In the following code, you learn how to create CallClient and CallAgent, which are necessary for the next steps. Then we join the Teams meeting, which creates a Call instance.

const { CallClient } = require('@azure/communication-calling');
const { AzureCommunicationTokenCredential} = require('@azure/communication-common');

const userToken = '<USER_TOKEN>';
callClient = new CallClient();
const tokenCredential = new AzureCommunicationTokenCredential(userToken);
const callAgent = await callClient.createCallAgent(tokenCredential);
const deviceManager = await callClient.getDeviceManager();

const meetingCall = callAgent.join({ meetingLink: '<MEETING_LINK>' });

Learn the current role

You create a 'Call' instance when you join the Teams meeting or Room with calling SDK. This object has a property role that can have one of the following values:

  • Unknown
  • Attendee
  • Presenter
  • Organizer
  • Consumer
const role = meetingCall.role;

Subscribe to role changes

During the Teams meeting or Room, your role can be changed. To learn about the change, subscribe to an event, roleChanged, on the Call object.

meetingCall.on('roleChanged', args => {
   role = meetingCall.role;
   // Update UI
}

Next steps