Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of Teams batch APIs #6655

Merged
merged 12 commits into from
Aug 16, 2023

Conversation

ceciliaavila
Copy link
Collaborator

@ceciliaavila ceciliaavila commented Jul 4, 2023

#minor

Description

This PR implements the new Teams batch APIs in TeamsOperations.

  • Send message to a list of users
  • Send message to all users in a tenant
  • Send message to all users in a team
  • Send message to a list of channels
  • Get Operation State
  • Get failed entries paginated
  • Cancel Operation

Specific Changes

  • Implemented the new methods in TeamsOperations, TeamsOperationsExtensions, and TeamsInfo.
  • Created Microsoft.Bot.Connector/RetryAction class to handle the retry logic of the operations.
  • Added BatchFailedEntriesResponse, BatchFailedEntry, and BatchOperationState classes in Bot.Schema/Teams to handle the operation response types.
  • Added unit test to cover the new methods.

Testing

These images show some of the new operations working.
image
image

@ceciliaavila ceciliaavila added the Automation: Parity with js The PR needs to be ported to JS label Jul 4, 2023
@ceciliaavila ceciliaavila marked this pull request as ready for review July 25, 2023 18:01
@ceciliaavila ceciliaavila requested a review from a team as a code owner July 25, 2023 18:01
/// The status map for processed users.
/// </value>
[JsonProperty(PropertyName = "statusMap")]
public IDictionary<string, int> StatusMap { get; } = new Dictionary<string, int>();
Copy link

@isiroshenko isiroshenko Aug 10, 2023

Choose a reason for hiding this comment

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

on our side it's Dictionary <int, int>, where key is statusCode

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed. Thanks!

/// <param name="tenantId"> The tenant ID. </param>
/// <param name="cancellationToken"> The cancellation token. </param>
/// <returns> The operation Id. </returns>
public static async Task<string> SendMessageToListOfUsersAsync(ITurnContext turnContext, IActivity activity, List<object> teamsMembers, string tenantId, CancellationToken cancellationToken = default)

Choose a reason for hiding this comment

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

Is there a reason why we're using object and not specifying a concrete type for list of members?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We created a TeamMember model with a string Id property to handle this.

{
if (operations is TeamsOperations teamsOperations)
{
using (var result = await teamsOperations.SendMessageToListOfUsersAsync(activity, teamsMembers, tenantId, null, cancellationToken).ConfigureAwait(false))

Choose a reason for hiding this comment

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

I'm not fully familiar with the implementation here, and I'm wondering why one of the parameters is always null, when we're calling methods from teamsOperations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The null parameter is for customHeaders that are used for creating the request. We removed the null value in the calls because it defaults to null.

/// </summary>
/// <value>The id of the failed entry.</value>
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }

Choose a reason for hiding this comment

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

in the response we are returning property name will be called "entryId"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed. Thanks!

@BruceHaley
Copy link
Contributor

✔️ No Binary Compatibility issues for Microsoft.Bot.Builder.dll
✔️ No Binary Compatibility issues for Microsoft.Bot.Connector.dll
✔️ No Binary Compatibility issues for Microsoft.Bot.Schema.dll

@tracyboehrer tracyboehrer merged commit c9d4d08 into main Aug 16, 2023
16 of 17 checks passed
@tracyboehrer tracyboehrer deleted the southworks/add/teams-batch-operations branch August 16, 2023 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Automation: Parity with js The PR needs to be ported to JS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants