TeamId is not always filled in OnTeamsMembersAddedAsync

%3CLINGO-SUB%20id%3D%22lingo-sub-1770714%22%20slang%3D%22en-US%22%3ETeamId%20is%20not%20always%20filled%20in%20OnTeamsMembersAddedAsync%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1770714%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20developed%20a%20bot%20for%20teams.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20a%20user%20install%20the%20bot%20on%20one%20of%20his%20channels%2C%20I%20want%20to%20save%20information%20about%20the%20channel%20(the%20TeamId%20and%20the%20TenantId)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20when%20OnTeamsMembersAddedAsync%20is%20called%2C%20the%20teamId%20is%20not%20always%20filled.%20And%20when%20it%20is%20missing%2C%20I%20have%20no%20way%20to%20get%20it%20via%20other%20properties.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20now%2C%20it%20seems%20a%20little%20random.%20Sometimes%20when%20I%20install%20the%20bot%2C%20the%20TeamId%20is%20filled%20sometimes%20not.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20better%20way%20to%20%22catch%22%20those%20information%20%3F%3C%2FP%3E%3CP%3EIs%20this%20a%20known%20issue%3F%3C%2FP%3E%3CP%3EAm%20I%20doing%20somethig%20wrong%20or%26nbsp%3B%20%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1770714%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1773955%22%20slang%3D%22en-US%22%3ERe%3A%20TeamId%20is%20not%20always%20filled%20in%20OnTeamsMembersAddedAsync%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1773955%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F828768%22%20target%3D%22_blank%22%3E%40YvanB%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECould%20you%20please%20try%20to%20get%20information%20from%20%22OnConversationUpdateActivityAsync%22%20method.%3CBR%20%2F%3EPlease%20go%20through%20below%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fdotnet%2Fapi%2Fmicrosoft.bot.builder.activityhandler.onconversationupdateactivityasync%3Fview%3Dbotbuilder-dotnet-stable%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Edocument%3C%2FA%3E%20for%20reference.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hello,

 

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  ?

 

Thanks

 

4 Replies
Highlighted

@YvanB 

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

Highlighted

@Rama-MSFT 

 

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

 

 

Highlighted

@YvanB 

 

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.

Rama-MSFT_0-1603455201442.png

 

Highlighted

@Rama-MSFT 

 

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.