@ravi , As we discussed this issue in call, please add your ngrok url in valid domains.
How to get TeamId and Channel Id in ConversationUpdate activity in Bot
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.
1 additional answer
Sort by: Most helpful
-
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.