botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Fetch unique encrypted user Id for MS Teams without user interacting with bot

Open ghost opened this issue 8 years ago • 10 comments

Issue Description

Bot should be able to send a proactive notification to users present in my active directory. How do I get unique encrypted user ID of a user who is present in my active directory without the user having to send a message to bot or how can I construct the unique user id using active directory's object id and app id of bot (was encryption algorithm is used).

ghost avatar Mar 14 '18 11:03 ghost

To my knowledge, you will not be able to send a proactive message in this context. This is intentional to prevent spambots within the bot framework. There is this doc in which they outline how to get data about members of your team https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/bots/bots-context#fetching-the-team-roster. So that part you can do. As far as sending a proactive mssage you will not have a conversation reference to use, so there will be no way to send a message unless the user has already engaged your bot in conversation.

JasonSowers avatar Mar 14 '18 19:03 JasonSowers

@JasonSowers But I think you should allow sending proactive notification in some way as the bot belongs to my org's active directory as well as the users to which bot wants to send messages belong to the same active directory. I agree your case of spaming users who belong to a different active directory but in my case as both the bot and users are of same org i should be able to send proactive notification. Can you please help?

rohankulkarni21 avatar Mar 15 '18 07:03 rohankulkarni21

You are welcome to create a feature request issue, but at this point this is not on our roadmap.

You could work around this by somehow requiring members of your organization to send a message to your bot, then you would have a conversation reference to use to send a proactive message.

JasonSowers avatar Mar 15 '18 17:03 JasonSowers

@JasonSowers can you provide me with a link to add a feature request?

rohankulkarni21 avatar Mar 16 '18 06:03 rohankulkarni21

Just open a new issue in this repo https://github.com/Microsoft/BotBuilder/issues/new asking for this feature to send proactive messages in team with no prior interaction.

JasonSowers avatar Mar 19 '18 22:03 JasonSowers

@JasonSowers as an option, you can try to install an app for the user and try to get chat to trigger memberAdded event. Sample https://github.com/OfficeDev/msteams-sample-contoso-hr-talent-app/blob/master/TeamsTalentMgmtApp/src/TeamsTalentMgmtAppV4/Services/GraphApiService.cs#L43

Ky7m avatar Jan 02 '20 20:01 Ky7m

@Ky7m also, we do now provide a sample demonstrating how to query the roster, and message members: https://github.com/microsoft/BotBuilder-Samples/blob/master/samples/csharp_dotnetcore/57.teams-conversation-bot/Bots/TeamsConversationBot.cs#L103

EricDahlvang avatar Jan 02 '20 20:01 EricDahlvang

@EricDahlvang if i'm getting correctly your example gets unique ID when already having conversation with user and knowing his turnContext.Activity.From.Id or knowing channel? But what if we want to make real proactive message just knowing user's email from our directory (as for spam issues - as some here told we already own this directory and have all admin rights)

Unders0n avatar Jul 15 '20 18:07 Unders0n

When the bot is installed into a team, it will receive a ConversationUpdate activity. This can be used to fetch the team roster.

EricDahlvang avatar Jul 15 '20 21:07 EricDahlvang

@EricDahlvang thanks, we've got IDs, but now i'm failing to send a message, when already having conversation and trying to call CreateDirectConversation im getting bad request and when following this example https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/conversations/send-proactive-messages?tabs=dotnet#obtain-necessary-user-information i also have issues which i explained here https://github.com/MicrosoftDocs/msteams-docs/issues/1895 , can you please check this?

Unders0n avatar Jul 16 '20 14:07 Unders0n