How to get TeamId and Channel Id in ConversationUpdate activity in Bot

ravi 21 Reputation points
2021-03-23T02:52:49.66+00:00

I have used following codes

TeamDetails teamDetails = await TeamsInfo.GetTeamDetailsAsync(turnContext, turnContext.Activity.TeamsGetTeamInfo().Id, cancellationToken);

public class MyBot : TeamsActivityHandler { protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken) { TeamDetails teamDetails = await TeamsInfo.GetTeamDetailsAsync(turnContext, turnContext.Activity.TeamsGetTeamInfo().Id, cancellationToken); if (teamDetails != null) { await turnContext.SendActivityAsync($"The groupId is: {teamDetails.AadGroupId}"); } else { await turnContext.SendActivityAsync($"Message did not come from a channel in a team."); } }

}

https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/get-teams-context?tabs=dotnet

I have used latest version of Microsoft.Bot.Schema and Microsoft.Bot.Builder i.e. v4.12.2

But no luck. Pls help.

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
746 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,246 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
2,847 questions
{count} votes

1 additional answer

Sort by: Most helpful
  1. Sridevi-MSFT 261 Reputation points
    2021-03-31T12:08:24.417+00:00

    Hi @ravi , Add your application to teams channel and call your bot with @BotName it will trigger to OnMessageActivityAsync method.

    83219-capture0001.png