TeamId is not always filled in OnTeamsMembersAddedAsync

Copper Contributor



I have developed a bot for teams.


When a user install the bot on one of his channels, I want to save information about the channel (the TeamId and the TenantId)


But when OnTeamsMembersAddedAsync is called, the teamId is not always filled. And when it is missing, I have no way to get it via other properties.


For now, it seems a little random. Sometimes when I install the bot, the TeamId is filled sometimes not.


Is there a better way to "catch" those information ?

Is this a known issue?

Am I doing somethig wrong or  ?




5 Replies


Could you please try to get information from "OnConversationUpdateActivityAsync" method.
Please go through below document for reference.



Thanks for the answer,


As there is several ways to get the teamId, I've implemented a method to get this information from the turnContext, teamInfo and the channelAccounts (I take the first non-null one).


Also as the OnConversationUpdateActivityAsync is just taking some information from the turnContext and then call the OnTeamsMembersAddedAsync method, I'm not sure I will get more information from this method.


I tried nonetheless and i've the same issue. The teamid is sometimes not in the turnContext





Firstly, we have to add our application in to channel, and please add any member to the team, now you you will hit the "OnTeamsMembersAddedAsync" method. Now you will receive the teamsid in the ChannelData.


Could you please have a look on below sreenshot.





Thanks for your answer,


I already get the teamsId from the channelData and my issue is not that I can't get the teamsId.

My issue is that sometimes , when the method OnTeamsMembersAddedAsync is called, I don't have the teamsId in the channelData.


It is hard to reproduce the issue. However what I know is that it can only happen when I install the bot to a channel.

@YvanB :


Hi YvanB,


When ever you don't find the teamsId in the channelData. Can you try re-installing the bot within the team and re-triggering the event, this should fix the issue.