microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.5k stars 2.44k forks source link

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

Closed ghost closed 6 years ago

ghost commented 6 years ago

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).

JasonSowers commented 6 years ago

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.

rohankulkarni21 commented 6 years ago

@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?

JasonSowers commented 6 years ago

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.

rohankulkarni21 commented 6 years ago

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

JasonSowers commented 6 years ago

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.

Ky7m commented 4 years ago

@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

EricDahlvang commented 4 years ago

@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

Unders0n commented 4 years ago

@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)

EricDahlvang commented 4 years ago

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

Unders0n commented 4 years ago

@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?