Flatten api clients#595
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request modernizes the Teams ApiClient conversation surface by flattening activity/member/reaction operations onto ConversationApiClient, while keeping the legacy sub-clients available but deprecated for compatibility.
Changes:
- Added direct activity, targeted-activity, member, and reaction methods to
ConversationApiClient; markedActivities,Members, andReactionssub-clients (and their classes) as[Obsolete]. - Introduced member pagination helpers (
GetMembersPagedAsync) and a streaming helper (GetAllMembersAsync) onConversationApiClient. - Updated integration tests, samples, and design documentation to use the flattened API surface.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/Microsoft.Teams.Apps/Api/Clients/ConversationApiClient.cs | Adds the flattened activities/members/reactions API surface and paging/streaming member helpers. |
| core/src/Microsoft.Teams.Apps/Api/Clients/ActivityClient.cs | Deprecates legacy activity sub-client. |
| core/src/Microsoft.Teams.Apps/Api/Clients/MemberClient.cs | Deprecates legacy member sub-client. |
| core/src/Microsoft.Teams.Apps/Api/Clients/ReactionClient.cs | Deprecates legacy reaction sub-client. |
| core/test/IntegrationTests/ApiClientTests.cs | Migrates tests to flattened conversation APIs. |
| core/test/IntegrationTests/CreateConversationTests.cs | Updates activity creation/reply calls to new direct methods. |
| core/test/IntegrationTests/IntegrationTestFixture.cs | Updates member retrieval to new conversation API surface. |
| core/test/IntegrationTests/CompatTeamsInfoTests.cs | Updates member retrieval call site to flattened API. |
| core/test/TeamsApisDemo/Program.cs | Updates demo code to use GetMembersPagedAsync directly on Conversations. |
| core/samples/TeamsBot/Program.cs | Updates sample to use flattened targeted activity + reaction methods. |
| core/samples/TargetedMessages/Program.cs | Updates sample to use flattened targeted activity methods. |
| core/docs/ApiClient-Design.md | Updates design doc to describe deprecated sub-clients and new direct APIs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| | Teams, Meetings | `BotHttpClient` directly | No core client exists for these endpoints | | ||
|
|
||
| **Experimental APIs:** `ReactionClient` (`ExperimentalTeamsReactions`); `ActivityClient.CreateTargetedAsync` / `UpdateTargetedAsync` / `DeleteTargetedAsync` (`ExperimentalTeamsTargeted`, not supported in team channels). | ||
| **Experimental APIs:** `ConversationApiClient.CreateTargetedActivityAsync` / `UpdateTargetedActivityAsync` (`ExperimentalTeamsTargeted`, not supported in team channels). |
There was a problem hiding this comment.
^ also missing the reaction ones
| } | ||
|
|
||
| /// <summary> | ||
| /// Delete a targeted activity from a conversation. |
There was a problem hiding this comment.
missing Experimental marker here also
| /// </summary> | ||
| public Task DeleteTargetedActivityAsync(string conversationId, string id, AgenticIdentity? agenticIdentity = null, Dictionary<string, string>? additionalHeaders = null, CancellationToken cancellationToken = default) | ||
| { | ||
| return _client.DeleteTargetedActivityAsync(conversationId, id, _serviceUrl, requestContext: BotRequestContext.FromAgenticIdentity(agenticIdentity), customHeaders: additionalHeaders, cancellationToken: cancellationToken); |
There was a problem hiding this comment.
should we update this to the implementation vs client call (to match the others)
| /// </summary> | ||
| public Task<T> GetMemberByIdAsync<T>(string conversationId, string memberId, AgenticIdentity? agenticIdentity = null, Dictionary<string, string>? additionalHeaders = null, CancellationToken cancellationToken = default) where T : ChannelAccount | ||
| { | ||
| return _client.GetConversationMemberAsync<T>(conversationId, memberId, _serviceUrl, requestContext: BotRequestContext.FromAgenticIdentity(agenticIdentity), customHeaders: additionalHeaders, cancellationToken: cancellationToken); |
There was a problem hiding this comment.
should we update this to the implementation also?
| /// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for the task to complete.</param> | ||
| public Task AddReactionAsync(string conversationId, string activityId, string reactionType, AgenticIdentity? agenticIdentity = null, Dictionary<string, string>? additionalHeaders = null, CancellationToken cancellationToken = default) | ||
| { | ||
| return _client.AddReactionAsync(conversationId, activityId, reactionType, _serviceUrl, requestContext: BotRequestContext.FromAgenticIdentity(agenticIdentity), customHeaders: additionalHeaders, cancellationToken: cancellationToken); |
There was a problem hiding this comment.
same impl question for these two reaction methods
This pull request modernizes the
ConversationApiClientby moving activity, member, and reaction operations directly onto the main client, deprecating the old sub-client classes and methods. It updates documentation and sample code to reflect these changes, and introduces new methods for member pagination and targeted activities. The changes improve usability and streamline the API surface, while retaining backward compatibility via obsolete sub-clients.Client API modernization:
CreateActivityAsync,GetMembersPagedAsync,AddReactionAsync) directly toConversationApiClient, deprecating theActivities,Members, andReactionssub-clients and marking them as[Obsolete]for backward compatibility. [1]], [2]], [3]], [4]])ConversationApiClient, includingGetMembersPagedAsync,GetAllMembersAsync(for streaming members with pagination), and overloads for getting a member by ID. ([core/src/Microsoft.Teams.Apps/Api/Clients/ConversationApiClient.csR60-R273])Targeted activities improvements:
CreateTargetedActivityAsync,UpdateTargetedActivityAsync, andDeleteTargetedActivityAsyncmethods toConversationApiClient, and deprecated the corresponding methods on the old sub-clients. ([core/src/Microsoft.Teams.Apps/Api/Clients/ConversationApiClient.csR60-R273])Reaction API improvements:
AddReactionAsyncandDeleteReactionAsyncmethods directly toConversationApiClient, deprecating the oldReactionClient. ([core/src/Microsoft.Teams.Apps/Api/Clients/ConversationApiClient.csR60-R273])Documentation and sample updates:
ApiClient-Design.mdto document the new API surface, clarify the deprecation of sub-clients, and provide updated usage examples. [1]], [2]], [3]])TeamsBot,TargetedMessages) to use the new direct methods onConversationApiClientinstead of the sub-client pattern. [1]], [2]], [3]], [4]], [5]], [6]], [7]])These changes make the API more intuitive and future-proof, while ensuring existing codebases continue to work with deprecation warnings.