Find Out Both Chat Participants In Ms Teams Tab (javascript)
Our applications has relationships between users, and we want to show the relationships in MS teams tabs. Imagine there's a chat between User A and User B in msteams. User A is cur
Solution 1:
There's a way to get all the members of the current conversation using the TurnContext.Conversation.GetConversationMembersAsync method, if you're using a Bot, written in C# (I'm sure there's an equivalent for a Bot in Node.js). What this means is that, if you add a Bot to your application as well as the existing Tab, you can query for the conversation members when the Bot is added to the group chat. When the Bot is added to the conversation, it receive a OnMembersAddedAsync event, where you could do the "GetConversationMembersAsync" call, something like this:
protected overrideTaskOnMembersAddedAsync(IList<ChannelAccount> membersAdded, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
{
List<ChannelAccount> teamMembers = (await turnContext.TurnState.Get<IConnectorClient>().Conversations.GetConversationMembersAsync(
turnContext.Activity.GetChannelData<TeamsChannelData>().Team.Id).ConfigureAwait(false)).ToList();
List<MicrosoftTeamUser> teamsUsers = new List<MicrosoftTeamsUser>();
foreach (var item in teamMembers)
{
var teamsUser =JsonConvert.DeserializeObject<MicrosoftTeamUser>(item.Properties.ToString());
teamsUser.Id= item.Id;
teamsUsers.Add(teamsUser);
}
}
You'll need a definition for MicrosoftTeamsUser, as follows:
publicclassMicrosoftTeamsUser
{
publicstring Id { get; set; }
publicstring ObjectId { get; set; }
publicstring GivenName { get; set; }
publicstring Surname { get; set; }
publicstring Email { get; set; }
publicstring UserPrincipalName { get; set; }
publicstring TenantId { get; set; }
}
Post a Comment for "Find Out Both Chat Participants In Ms Teams Tab (javascript)"