简体   繁体   中英

Teams UpdateActivity events difference when you test in newly created teams

We have a Teams bot that posts messages in MS Teams. The first activity of a new conversation is always an adaptive card and once in a while, we update that with a new card. This worked OK until I made a new Team with this bot.

The update we are trying with UpdateActivityAsync, return NotFound.

After some troubleshooting, I noticed the following:

  1. The new team has a different name: 19:...@thread.tacv2 as opposed to 19:...@thread.skype.
  2. When I use an older team, it works as expected.
  3. When I update the activity with text only (so no adaptive card as attachment) it will always update as expected.
  4. After an update with a text, we are able to update with an adaptive card ONCE. After one update with an adaptive card, any subsequent updates with adaptive cards will return NotFound.
  5. So, as a workaround, I now first update with text and immediately after that I send the update with the card. Which is a bad UI thing (flickering) but it works for now.

We use the old bot framework version 3, which I know is not maintained anymore, but as far as I can find, it should still work (no plans to discontinue operation). Also given the above points (specifically point 4) I would expect it uses the same calls under the hood.

So, this works for older teams, but not for a team with @thread.tacv2

await connector.Conversations.UpdateActivityAsync(
      teamsConversationId,
      activityId,
      (Activity)messageWithCard);

And for teams with @thread.tacv2 we now have to use this

var messageWithText = Activity.CreateMessageActivity();
messageWithText.ChannelId = teamsConversationId;
messageWithText.Id = activityId;
messageWithText.Type = ActivityTypes.Message;
messageWithText.Text = "Updated";

await connector.Conversations.UpdateActivityAsync(
      teamsConversationId,
      activityId,
      (Activity)messageWithText);

await connector.Conversations.UpdateActivityAsync(
      teamsConversationId,
      activityId,
      (Activity)messageWithCard);

The exception does not provide too many details:

Operation returned an invalid status code 'NotFound'

Conversation not found.

Does anyone know how to avoid this change between teams and allow updates of activity with cards?

Also (and this is much less important, but I think it's useful to add) I noticed that sometimes (I've seen it twice now) Teams seems unable to render the adaptive card and displays URIObject XML instead, containing error: cards.unsupported. However, if I exit the client and restart it, it renders fine... I have never seen this so far in the old channels.

Teams client version 1.3.00.362 (64-bit) (no dev mode). Normal Azure tenant (no preview/trial)

EDIT 11/05/2020 It seems that this also happens on teams with the 'old' name (@thread.skype). So the '@thread.tacv2' seems unrelated.

We weren't able to find logs at the exact timestamps that you provided, but did find logs for the conversation ids on those dates and see 404s with the same minute and seconds in UTC. We assume the time stamps that were provided are represented in a different timezone.

From the logs we are seeing the following pattern:

Bot sends PUT activity with card - 404 returned
Bot sends PUT activity with text - 200 returned
Bot sends PUT activity with card - 200 returned

This looks like the same pattern that you shared in your original post.

There is a scenario that's causing 404s to be returned on PUTS whenever the bot tries to update an existing card message with the exact same card after new messages have been sent to a reply chain

These are the repo steps:

 Bot send card to reply chain (can be root message or reply message)
    Any user sends a message to the chain
    Bot attempts to update message with the exact same card

Is it possible that your bot is encountering this? Is there a way to check whether the card your bot is sending in the first PUT request is the same card that is already in the original message

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM