microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

In Microsoft Teams, <Conversation>.ReplyToActivity does not send a reply, it creates a new message to the conversation

tomorgan opened this issue · comments

Github issues should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.

Version

Microsoft.Bot.Builder 4.21.2 .NET SDK

Describe the bug

The ConnectorClient.Conversations object has a method, SendToConversation(Async), which is used to send new message threads into a conversation. (a conversation in this instance could be 1:1 conversation with a user, or a channel chat). The method accepts an activity object and a conversation ID, and returns an Activity ID of the newly created activity.
There is also a ReplyToActivityAsync method, which takes a single parameter, an Activity object. However, even when a message has a valid ReplyToID value, the reply is sent to Microsoft Teams as a new message, not a threaded reply.
There is also a ConversationExtension method ReplyToActivityAsync, which exhibits the same behaviour.

To Reproduce

  1. Create a new activity, using a ReplyToId of an existing activity that has previously been sent to Microsoft Teams, using the existing activity ID and conversation ID where the original message was sent:
    IMessageActivity newMessage = Activity.CreateMessageActivity();
    newMessage.Type = ActivityTypes.Message;
    newMessage.Text = messageText;
    newMessage.ReplyToId = {activity_id};
    newMessage.Conversation = new ConversationAccount();
    newMessage.Conversation.Id = {conversation_id};
  2. Use ReplyToActivityAsync to send the message:
    var response = await connector.Conversations.ReplyToActivityAsync((Activity)message);
  3. Message is sent to Microsoft Teams as a new message, not as a threaded reply. No error is produced. This is most obvious in channel conversations, which can have multiple concurrent conversations happening at any one time.

Expected behavior

The message should be sent as a threaded reply to the provided activity.

Tracking Status

Dotnet SDK TODO

  • PR
  • Merged

Javascript SDK TODO

  • PR
  • Merged

Python SDK TODO

  • PR
  • Merged

Java SDK TODO

  • PR
  • Merged

Samples TODO

  • PR
  • Merged

Docs TODO

  • PR
  • Merged

Tools TODO

  • PR
  • Merged

looks like this feature request? https://techcommunity.microsoft.com/t5/teams-developer/how-to-send-a-message-to-a-thread-reply-using-botbuilder-4-0-sdk/m-p/3716974

I think this bug / missing feature is very annoying, especially since we make heavy use of group chats.

I think it's probably the same code, albeit a different usage scenario. In the other example, there was (I think) a 1-2-1 conversation between a user and a bot, where the OP wanted to perform a threaded reply.
In my example, it's a channel conversation where I want to perform a standard reply to a channel post, rather than starting a new post.
Quite possibly the code path is the same though.

But also - I would argue that the presence in the SDK of a ReplyToActivityAsync method, which does not actually perform a reply, is a bug and not a missing feature!

In hope this saves someone some time, we got replies working like this:
connector.Conversations.SendToConversationAsync($"{groupChatId};messageid={conversationId}", (Activity) message);

Anxiously waiting to see something happen with this.

In hope this saves someone some time, we got replies working like this: connector.Conversations.SendToConversationAsync($"{groupChatId};messageid={conversationId}", (Activity) message);

thank you, it looks great. There my code,

await connectorClient.conversations.sendToConversation(
          `${conversation_id};messageid=${activity_id}`,
          replyCard
        )