Forum Discussion
Teams Notification Bot: TeamsInfo.getPagedMembers is sometimes not returning newly added members
Thanks.
- alexkovalevDec 24, 2021Copper Contributor
Hi, yes we still need help with this issue. Here is some additional information that you asked for:
1) These users are being added to the channel after the bot has been installed
2) The bot is detecting some users, but not all. See the following screenshots for our tenant, where I checkmarked the users being detected:
ā
The users marked in red are the ones not being detected by the bot, and the blue ones are being detected. The way we create users is:
- Create a new user in admin.microsoft.com
- Add this new user to a MS Teams team/channel as an admin
The only difference between the working and non-working users is that the working ones we added a while back, and the non-working ones are all new users from us trying to reproduce the issue.
To confirm, here is my backend code, printing out the resulting list "members" confirms that only the 3 checkmarked emails are being detected:const members = []; do { var pagedMembers = await TeamsInfo.getPagedMembers(context, 100, continuationToken); continuationToken = pagedMembers.continuationToken; members.push(...pagedMembers.members.filter(m => !!m.email)); } while (continuationToken !== undefined);
- HunaidHanfee-MSFTDec 30, 2021Iron ContributorHello @aelxkovalev,
Can you please try once with nodeJs sample once and see if you are getting all member or is it the same behavior?
Here the link - https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/javascript_nodejs/57.teams-conversation-bot
Thanks- alexkovalevDec 30, 2021Copper ContributorHi, we were finally able to get to the bottom of this issue. The problem was in this line: members.push(...pagedMembers.members.filter(m => !!m.email));
The problem is that the email property doesnt exist on the users with issues, but it seems another field userPrincipalName is available with the user email for both the users that have the email field and dont.
Can you confirm if this is the correct solution, and if there are any unintended side effects with changing the code to read from email to userPrincipalName?
- HunaidHanfee-MSFTDec 28, 2021Iron Contributor
alexkovalev - I have tried myself and unable to have the repro at my end. I am getting all the user added as member or owner with the method -
I am trying more to see if it there's some scenario when it doesn't work. Meanwhile can you try removing bot from team and install again or maybe check with other team if it working fine there.
- HunaidHanfee-MSFTDec 27, 2021Iron ContributorThanks for the response, I will give it a try and see if it's repro at my end as well.
I will keep you posted.