A free program from Microsoft that provides developers with the tools, resources, and sandbox environments needed to build solutions for Microsoft 365.
Thanks for reaching out to Microsoft Q&A forum support
Based on your description, I understand that you're building a Microsoft Teams bot using the Bot Framework and Microsoft Graph API. You have two main concerns:
- You want to proactively message a user who has not yet interacted with the bot, and you currently only have their Entra ID, not their Teams user ID or conversation reference.
- You need to retrieve all channels and tags from a specific Team using the Team ID, including channel IDs, tag IDs, tag names, and associated members.
Regarding to your first question, as far as I know, proactive messaging in Microsoft Teams bots requires a valid conversation reference, which is typically obtained when a user first interacts with the bot. If the user has not interacted yet, you cannot directly send a message using only the Entra ID.
However, Microsoft Graph API provides a workaround: you can proactively install the bot for the user and then initiate a conversation, you can try this API method to see if the issue can be resolved:
POST /users/{user-id}/teamwork/installedApps
Required permissions: TeamsAppInstallation.ReadWriteSelfForUser.All (Application permission)
Create a conversation: After installation, use the Bot Framework to create a conversation and send a proactive message. This typically involves capturing the conversation reference via a conversationUpdate event or using POST /v3/conversations.
Link references:
- Graph API for proactive installation
- https://github.com/officedev/microsoft-teams-samples/tree/main/samples/graph-proactive-installation/csharp
- https://learn.microsoft.com/en-us/graph/api/userteamwork-post-installedapps?view=graph-rest-1.0&tabs=http
Regarding to your second question, if you want to retrieve channels and tags from a specific Team using its Team ID, you can use the following Microsoft Graph API endpoints:
For channel:
#List all channel
GET /teams/{team-id}/channels
#Get a specific channel
GET /teams/{team-id}/channels/{channel-id}
#Get the primary channel
GET /teams/{team-id}/primaryChannel
For tag:
#List all tags
GET /teams/{team-id}/tags
#Get members of a tag
GET /teams/{team-id}/tags/{tag-id}/members
Required permissions:
- For channels:
- Delegated:
Channel.ReadBasic.All- Application:
ChannelSettings.Read.Group,ChannelSettings.ReadWrite.Group
- Application:
- Delegated:
- For tags:
- Delegated:
TeamworkTag.Read.All- Application:
TeamworkTag.ReadWrite.All
- Application:
Reference documentation:
However, I think that you should consider implementing a proactive installation flow where your bot installs itself for users based on their Entra ID and then initiates a conversation. This ensures you can reach users even if they haven’t interacted with the bot yet.
For retrieving channels and tags, ensure your app has the correct permissions and that consent is granted for application-level access if needed. You may also want to cache channel and tag metadata for performance optimization if your bot frequently accesses this data.
Hope my answer will help you
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.