Skip to content

Flatten api clients#595

Open
MehakBindra wants to merge 2 commits into
mainfrom
core/api-flatten
Open

Flatten api clients#595
MehakBindra wants to merge 2 commits into
mainfrom
core/api-flatten

Conversation

@MehakBindra

@MehakBindra MehakBindra commented Jul 9, 2026

Copy link
Copy Markdown
Member

This pull request modernizes the ConversationApiClient by 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:

  • Added activity, member, and reaction methods (e.g., CreateActivityAsync, GetMembersPagedAsync, AddReactionAsync) directly to ConversationApiClient, deprecating the Activities, Members, and Reactions sub-clients and marking them as [Obsolete] for backward compatibility. [1]], [2]], [3]], [4]])
  • Introduced new member-related methods on ConversationApiClient, including GetMembersPagedAsync, 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:

Reaction API improvements:

Documentation and sample updates:

  • Updated ApiClient-Design.md to document the new API surface, clarify the deprecation of sub-clients, and provide updated usage examples. [1]], [2]], [3]])
  • Refactored all samples (TeamsBot, TargetedMessages) to use the new direct methods on ConversationApiClient instead 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.

Copilot AI review requested due to automatic review settings July 9, 2026 00:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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; marked Activities, Members, and Reactions sub-clients (and their classes) as [Obsolete].
  • Introduced member pagination helpers (GetMembersPagedAsync) and a streaming helper (GetAllMembersAsync) on ConversationApiClient.
  • 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).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ also missing the reaction ones

Comment thread core/docs/ApiClient-Design.md
Comment thread core/test/IntegrationTests/IntegrationTestFixture.cs
Comment thread core/test/IntegrationTests/CompatTeamsInfoTests.cs
Comment thread core/test/IntegrationTests/ApiClientTests.cs
Comment thread core/src/Microsoft.Teams.Apps/Api/Clients/ConversationApiClient.cs
Comment thread core/docs/ApiClient-Design.md
@MehakBindra MehakBindra requested a review from lilyydu July 9, 2026 19:21
}

/// <summary>
/// Delete a targeted activity from a conversation.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same impl question for these two reaction methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants