Botbuilder-dotnet: [MsTeams]-Getting the user Unique Id in Teams based on User Email

Created on 24 Dec 2019  路  8Comments  路  Source: microsoft/botbuilder-dotnet

  • Hi,
  • Can we get the user Unique id(activity.from.id) of the user using email in Teams.
    -I am able to get the user details using UniqueID but I want to get the same unique ID using Email of that user.
  • I want this unique ID so that I can send Proactive messages to the user.
  • Basically the solution to send proactive messages users using Unique ID. We are storing Unique Id in DB and sending Notifications but we are facing issue when user does not have any conversation with bot
    Thanks
Bot Services customer-replied-to customer-reported

Most helpful comment

We provide a sample demonstrating how to query the roster, and proactively message members of a team: https://github.com/microsoft/BotBuilder-Samples/blob/master/samples/csharp_dotnetcore/57.teams-conversation-bot/Bots/TeamsConversationBot.cs#L103

All 8 comments

To be clear, are you trying to send a proactive message to the user's emails? It would be easier to help if we understood what you were actually trying to do. It's possible to proactively message your team through Teams, by building your own conversation ID.

Hi ,
Yes I'm trying to send the proactive messages to user using activity.from.id(uniqueID) coming from Teams.

This is how I am sending proactive message:-
TenantInfo Tenant = new TenantInfo();
Tenant.Id = TenantID;//teams ID
ConnectorClient connectorClient = new ConnectorClient(new Uri(serviceUrl), msBotID, msBotPassword);
ConversationParameters parameters = new ConversationParameters
{
Bot = new ChannelAccount(botId, botName),
Members = new ChannelAccount[] { new ChannelAccount(UserUniqueID) }, //unique user id (Guid) coming from teams.(saving in database when user chats with bot) .
ChannelData = new TeamsChannelData
{
Tenant = Tenant
}
};

ConversationResourceResponse conversationResource = await connectorClient.Conversations.CreateConversationAsync(parameters);
var message = Activity.CreateMessageActivity();
message.From = new ChannelAccount(botId, botName);
message.Conversation = new ConversationAccount(id: conversationResource.Id.ToString());
message.Text ="Hello, This is the notification in Teams...";
await connectorClient.Conversations.SendToConversationAsync((Activity)message);

  • Here I can send notifications(proactive messages) to user who have already chatted with bot.
    -Can we create conversation ID of the user who have not chatted with bot?

Hello,

My issue is similar to this :- https://github.com/microsoft/botframework-sdk/issues/4312

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

We provide a sample demonstrating how to query the roster, and proactively message members of a team: https://github.com/microsoft/BotBuilder-Samples/blob/master/samples/csharp_dotnetcore/57.teams-conversation-bot/Bots/TeamsConversationBot.cs#L103

@Chekrii, did @Ky7m and @EricDahlvang 's solutions help you?

HI @jwiley84 ,

Thanks a lot. It helped me.

Alright! I'm going to go ahead an close this issue. If you have further issues, please feel free to open new tickets, here or on stack overflow!

Was this page helpful?
0 / 5 - 0 ratings