skip to Main Content

I’m having some major issues optimizing a notification bot made with Teams Toolkit.

My main problem is that:

const member = await notificationApp.notification.findMember( async (m) => m.account.email === email );

It takes too long. With barely 50 members, it takes 1 minute to execute that, which means that to send 50 single messages it’s taking almost one hour.

So I hosted a Redis service on Azure, and I wanted to save the user inside Redis, reducing the time to read the user. The problem is that I cannot build the Member from the info I’m saving on Redis. Considering that I can just save JSON on Redis, I saved what I could and I’m trying to build Member class from its constructor. This is more or less what I have done:

let memberFromRedis = await getMemberFromRedis(email); const account = memberFromRedis["account"] as TeamsChannelAccount; 
const conversationReference = memberFromRedis["parent"]["conversationReference"]; 
const teamsBotInstallation = await notificationApp.notification.buildTeamsBotInstallation(conversationReference); 
// @ts-ignore const user = new Member(teamsBotInstallation , account);

I’m using ts-ignore because I’m getting this weird type of
error :

translated it’s:

Argument type ‘TeamsBotInstallation_2’ it is not assignable to
parameeter type ‘TeamsBotInstallation’. Types of property ‘adapter’
are not compatible. In the type ‘CloudAdapter’ are missing the
following properties of the type ‘BotFrameworkAdapter’:
TokenApiClientCredentialKey, credentials, credentialsProvider,
settings and other 41.

but inside the types I can see:
TeamsBotInstallation_2 as TeamsBotInstallation,

so they should be the same type right?

anyway, debugging this code seems the user is the same but when I come to

await user.sendMessage("test");

I’m getting this
error :

{ "code": "Internal", "message": "Error:CloudAdapterBase.continueConversationis deprecated, please useCloudAdapterBase.continueConversationAsync" } 

for some reason, the type coming back from findMember (Member_2) looks slightly different from the Member class, even tho in this case as well I can see from types export Member_2 as Member, so I expect them to be the same.

With some breakpoints, I can notice just a small:
difference

the functions (not just this one but sendAdaptiveCard and the others
as well) seem to point to different locations, the type of the object
seems different..

is this normal or is this the problem? anyway, how can I solve that?

I tried creating the Member from its constructor, parsing with JSON, parsing with ‘as Member’, and tried everything, but no way to get this work.

2

Answers


  1. Issue Summary:
    You are facing issues with the Member class and the sendMessage method in your notification bot built with Teams Toolkit, encountering type incompatibility and deprecation warnings.
    Understanding the Issue:

    1. Type Incompatibility: The error about ‘TeamsBotInstallation_2’ not being assignable to ‘TeamsBotInstallation’ suggests a type mismatch, despite being exported as the same type. There might be underlying differences.
    2. Deprecation Warning: The warning indicates CloudAdapterBase.continueConversation is deprecated; use CloudAdapterBase.continueConversationAsync instead.
      Solution Steps:
    3. Type Compatibility Issue:
    • Ensure correct type usage throughout your code.
    • Explicitly cast objects to the correct type if necessary, e.g., const user = new Member(teamsBotInstallation as TeamsBotInstallation, account);.
    1. Deprecation of continueConversation:
    • Switch to continueConversationAsync as recommended.
    1. Alternative Approach:
    • Use the Member object returned by the findMember method directly to avoid compatibility issues.
      Code Adjustment:
    // Assuming you have retrieved the member directly from findMember method
    const member = await notificationApp.notification.findMember(async (m) => m.account.email === email);
    // Use the member directly to send a message
    await member.sendMessage("test");
    

    By directly using the Member object from findMember, you avoid type compatibility issues and deprecated methods.

    Additional Resources:

    Following the steps and ensuring correct usage of types and methods should resolve your notification bot issues in Teams Toolkit.

    Login or Signup to reply.
  2. Same question in Teams Toolkit GitHub Discussion is also replied.

    There’re two Member types in TeamsFx SDK:

    1. (conversation) Member
    2. (conversationWithCloudAdapter) Member

    The first one is actually deprecated as one of its property (conversation) TeamsBotInstallation is deprecated and it’s recommend to use the new type with the same name (conversationWithCloudAdapter) TeamsBotInstallation

    There’s type error from your code is, type of (conversationWithCloudAdapter) TeamsBotInstallation is retuned by buildTeamsBotInstallation, while the constructor of (conversation) Member requires type of (conversation) TeamsBotInstallation

    For your issue, you may take a look at the sample app of Large Scale Notification Bot if you have performance concerns about sending notifications.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search