Is it possible to get the Unique ID for the bot in a Teams meeting chat using the Graph API?

Leo Messi 20 Reputation points
2023-09-07T04:54:19.4133333+00:00

The Bot Framework schema defines the "Activity" object which defines a message that is exchanged between bot and user. This Activity object has the property "recipient" which holds a ChannelAccount object that specifies the recipient of the message which in our case is the bot that we added in the teams meeting chat. If the recipient is a bot since I am essentially trying to send a message to the bot added in the meeting chat, how do I find the "id" of the bot which refers to Unique ID for the user or bot on this channel using the Graph API? I have been able to find the unique id of the members using "/v3/conversations/{conversationId}/pagedmembers?pageSize={pageSize}&continuationToken={continuationToken}" , so I was wondering if we can access the unique bot id in the chat using something similar or the graph api?

I know it is possible to get the activity from the bot app I built(https://github.com/OfficeDev/Microsoft-Teams-Samples/tree/main/samples/meetings-notification/nodejs) using context.activity when I send a message to the bot from the meeting chat. But my goal is to send the message to the bot from Postman by attaching the same JSON payload that would have got sent to the bot if we had sent a message from the meeting chat. As a result, I would need a way to get the unique bot id of the bot in a specific chat.

Botframework schema documentation- https://learn.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference?view=azure-bot-service-4.0#channelaccount-object

User's image

User's image

A bot can access additional context data about a team or chat where it's installed.

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
833 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,000 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,250 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Prasad-MSFT 6,766 Reputation points Microsoft Vendor
    2023-09-08T06:59:26.7433333+00:00

    To find the unique ID of a bot in a specific chat, you can use the Microsoft Graph API.

    1. Get the conversation ID of the chat where the bot is added. You can retrieve the conversation ID by making a GET request to /v3/conversations/{conversationId}.
      The conversation ID uniquely identifies the chat.
    2. Once you have the conversation ID, you can use the Microsoft Graph API to get the list of members in the conversation.
      Make a GET request to /v1.0/chats/{chatId}/members to retrieve the list of members in the chat.
    3. Iterate through the list of members and find the member with the userType set to "bot". The id property of this member will be the unique ID of the bot in the chat.

    Once you have the unique bot ID, you can use it as the recipient in the Activity object when sending a message to the bot from Postman or any other client.

    Thanks, 

    Prasad Das

    ************************************************************************* 

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


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.