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

FindMember - API is very slow after adding 600+ conversations into storage #12562

Open
inopassdev opened this issue Oct 21, 2024 · 4 comments
Open
Assignees
Labels
enhancement New feature or request investigating TA:Infra Team Area: Infra

Comments

@inopassdev
Copy link

Describe the bug

On the TeamsFX - TypeScript, the findMember method has become very slow since I have more than 600 persisted conversations in my storage.
When I first put my Teams Bot into production, sending proactive notifications to a Teams user took about 7 seconds (With less conversations stored ~10), now it's 15 minutes.

To Reproduce
Steps to reproduce the behavior:

  1. Send any adaptive card to my endpoint (See code below)
  2. The request is being processed
  3. findMember list every conversations on the storage, get them and try to get member informations from an MS API.
  4. The user receive the notification, 15-20min after the request started to be processed

More details
The bot only send notifications to my users.
To find the right user, I use the findMember method available on BotBuilderCloudAdapter.ConversationBot class.
The condition used for matching is member.account.email === email.
1:1 conversations are stored in an Azure blob storage compatible bucket.

VS Code Extension Information (please complete the following information):

          const member = await notificationApp.notification.findMember(
            m => {
              return Promise.resolve(m.account.email === data.email)
            }, BotBuilderCloudAdapter.SearchScope.Person);

          await member?.sendAdaptiveCard(
            AdaptiveCards.declare(notificationTemplate).render({
              title: data.header,
              message:  data.message
            })
// Create bot.
export const notificationApp = new ConversationBot({
  // The bot id and password to create CloudAdapter.
  // See https://aka.ms/about-bot-adapter to learn more about adapters.
  adapterConfig: {
    MicrosoftAppId: config.botId,
    MicrosoftAppPassword: config.botPassword,
    MicrosoftAppType: "MultiTenant",
  },
  // Enable notification
  notification: {
    enabled: true,
    store: new BlobStore(connectionString, containerName),

  },
});
Copy link
Contributor

Thank you for contacting us! Any issue or feedback from you is quite important to us. We will do our best to fully respond to your issue as soon as possible. Sometimes additional investigations may be needed, we will usually get back to you within 2 days by adding comments to this issue. Please stay tuned.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs attention This issue needs the attention of a contributor. label Oct 21, 2024
@inopassdev inopassdev changed the title FindMember - API is very slow after adding 600+ conversations into store FindMember - API is very slow after adding 600+ conversations into storage Oct 21, 2024
@adashen adashen added investigating TA:Infra Team Area: Infra labels Oct 22, 2024
@swatDong swatDong added the enhancement New feature or request label Oct 22, 2024
@swatDong
Copy link
Contributor

Since currently there's no cache inside TeamsFx SDK, it's expected the two sets of remote calls taking time.

  1. list all person targets from BlobStore
  2. get member details by calling TeamsInfo.getPagedMembers

For now one workaround is to add logic to your BlobStore.add, e.g.,

  • record user email when adding the conversation reference
  • support get conversation reference by user email
  • create target by new TeamsBotInstallation(adapter, reference, botAppId)

@adashen adashen removed the needs attention This issue needs the attention of a contributor. label Oct 23, 2024
@inopassdev
Copy link
Author

Since currently there's no cache inside TeamsFx SDK, it's expected the two sets of remote calls taking time.

  1. list all person targets from BlobStore
  2. get member details by calling TeamsInfo.getPagedMembers

For now one workaround is to add logic to your BlobStore.add, e.g.,

  • record user email when adding the conversation reference
  • support get conversation reference by user email
  • create target by new TeamsBotInstallation(adapter, reference, botAppId)

Thanks for responding to this.

Do you have any sample code to store email and get conversation reference by email?

@swatDong
Copy link
Contributor

It depends how your ConversationReferenceStore implemented.
Here's the partial sample to get email by ConversationReference:

... conversationRef: ConversationReference;
let account;
await adapter.continueConversationAsync(
  botAppId,
  conversationRef,
  async (context) => {
      account = await TeamsInfo.getMember(context, context.activity.user.id);
  }
);
account.email ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request investigating TA:Infra Team Area: Infra
Projects
None yet
Development

No branches or pull requests

3 participants