question

ravi-4219 avatar image
0 Votes"
ravi-4219 asked Sridevi-MSFT answered

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://docs.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.

dotnet-csharpoffice-teams-app-devazure-bot-service
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@ravi-4219 I have found one SO thread with a similar discussion. I hope this information could help.


0 Votes 0 ·

@romungi-MSFT I tried but didn't work

0 Votes 0 ·

@ravi-4219

Our forum is mainly focused on the general issue of Microsoft Teams. According to your description, your issue is related to development, which we do not support. I will add teams-dev-app tag and delete office-teams tag.
For Teams client, if you want to get Teams ID or Channel ID, you can achieve it from Teams channel link. For more details, you can refer to:

https://www.c-sharpcorner.com/blogs/how-to-fetch-the-teams-id-and-channel-id-for-microsoft-teams

Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


0 Votes 0 ·
Show more comments
Sridevi-MSFT avatar image
0 Votes"
Sridevi-MSFT answered

@ravi-4219, As we discussed this issue in call, please add your ngrok url in valid domains.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Sridevi-MSFT avatar image
0 Votes"
Sridevi-MSFT answered ravi-4219 commented

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


83219-capture0001.png



capture0001.png (236.8 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Sridevi-MSFT I m getting TeamId onMessageActivityAsync but I need teamid when we first add bot to teams . That means we need teamid on ConversationUpdate activitytype in functions like OnTurnAsync or OnTeamsMembersAddedAsync

But no luck and getting teamid null pls go through the document as follows:
83220-addbottoteams-gettingteamidnull.pdf




If that not possible ,pls can you elaborate how can I trigger onMessageActivityAsync while adding bot first time to teams or on ConversationUpdate activity type.


0 Votes 0 ·