question

AtulSingh-4556 avatar image
0 Votes"
AtulSingh-4556 asked HunaidHanfee-MSFT commented

How to get the specific userId for communication between a bot and a particular user

A microsoft teams bot uses a specific user id for communication between bot and a user. This ID is unique for communication between these two. I am trying to get this ID for proactive messaging. I have seen many samples where we get this ID from a particular team channel or between a group chat. But, the problem is i want to get the userID of a user who is not a part of this chat.



Example -: If an employee submits a request using bot then his manager should be notified about that request proactively by the bot. How can i achieve that using the Application scope.

The bot is installed for bot employee and manager.

I couldn't find any example where i can send a message from bot to user of AD or any teams user for that matter even if the bot is installed for them.

office-teams-app-devazure-bot-service
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@AtulSingh-4556 I have added the teams tag to this question so others could chip in w.r.t getting the user id with teams.
I found an interesting conversation about a similar scenario that was achieved by a user to send a message proactively to a certain user based on action of another user. I hope this could help to find a similar solution .


0 Votes 0 ·

1 Answer

HunaidHanfee-MSFT avatar image
2 Votes"
HunaidHanfee-MSFT answered HunaidHanfee-MSFT commented

Hey,
If the bot is installed for both of them already, then you will need conversationId to send notification. You can get the conversation Id from turnContext.Activity.Conversation.Id and store it. You can get this when user install the bot (using OnConversationUpdateActivity)or when user interacts with the bot.

You can get user details from turnContext when user install the bot. If using OnConversationUpdateActivity then you can get it by turnContext.Activity.From. (have a look at available properties)
Thanks,

Hunaid Hanfee



If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Yeah , this helps .

1 Vote 1 ·

@AtulSingh-4556, Please Accept Answer and upvote it.

0 Votes 0 ·