12

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.

user1515791
  • 675
  • 4
  • 20
  • Currently team id contains the message id appended with it. The format will be look like this '19:xxxxxxxxxxxxxxxxxxxxxxxab@thread.skype;messageid=1xxxxxxxxxx6. This is in Bot builder SDK v4. Please take a look [Bot builder SDK v4 sample code](https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore) – Trinetra-MSFT Feb 28 '20 at 12:54
  • Thank you for your answer, however the id for the activity is not the problem, given that we are able to update it text only, update it with adaptive card once and (for instance) use GetActivityMembers without problems as well as that teams in the @thread.skype works as intended. – user1515791 Feb 28 '20 at 18:25
  • 1
    There is a bug in Teams, where if you send a message from the bot with text AND an attachment it will not return a resourceresonse.id. it looks like you are updating the same message.text AND the adaptive card. Try just updating the card, and include your .text IN the card as a workaround. – Eric Dahlvang Feb 29 '20 at 21:30
  • Our initial message is a card only and the id is saved without problems. (if i try to update with card attachment and text, itll throw a BadReques). Our update is as well only a card as attachment. Though while testing (and workaround) we now update first text-only, then card-only. – user1515791 Mar 02 '20 at 13:01
  • 1
    We have a open Bug for this will update you once it is fixed – Trinetra-MSFT Mar 16 '20 at 07:14
  • Are you able still able to reproduce the issue? If so, could you please repro in an empty test channel and share the channel id with a timestamp? We'll be able to use this info to investigate the service logs. – Wajeed Shaikh May 06 '20 at 18:30
  • I tried to replicate the issue with a new (empty) channel, but it didn't occur. However, the problem itself is stil occuring (a lot). I can give you timestamps and conversation ids for those.. – user1515791 May 07 '20 at 13:51
  • That would also be helpful. Can you please share some timestamps and conversation ids of occurrences within the last 20 days? – Wajeed Shaikh May 10 '20 at 16:26
  • In contrary that what i wrote in the post, it's not only happening in the 'new' channels.. 5/11, 12:55:50.455 PM 19:570019c5615b4385a47b1a04a0a234a5@thread.tacv2;messageid=1589194543567 5/11, 12:19:16.583 PM 19:72273c2612e04fbb8a7f3a560c3039da@thread.skype;messageid=1589191704292 5/8, 3:59:47.842 PM 19:72273c2612e04fbb8a7f3a560c3039da@thread.skype;messageid=1588946383699 5/8, 10:25:17.462 AM 19:aad3fa5655a34166b3ecf2aa98e56669@thread.skype;messageid=1588926249408 – user1515791 May 11 '20 at 11:23

1 Answers1

1

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

Trinetra-MSFT
  • 957
  • 5
  • 9
  • I need to add some additional logging to confirm. Will do so asap. However, we include a timestamp in the card. So my first response would be that the card will be largely the same, but not entirely. I will get back on this next week. – user1515791 May 20 '20 at 12:57
  • Sorry for the extreme late reply, however, since this month the errors seem not to happen anymore. The last occurence is 29/05. – user1515791 Jun 18 '20 at 11:24
  • Glad to hear this is fixed now – Trinetra-MSFT Jun 19 '20 at 05:51