microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.5k stars 2.45k forks source link

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

Open tomorgan opened 11 months ago

tomorgan commented 11 months ago

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]()

Javascript SDK [TODO]()

Python SDK [TODO]()

Java SDK [TODO]()

Samples [TODO]()

Docs [TODO]()

Tools [TODO]()

patst commented 10 months ago

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.

tomorgan commented 10 months ago

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!

AlexOSIT commented 8 months ago

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

dan-schroeder commented 8 months ago

Anxiously waiting to see something happen with this.

GraceWalk commented 5 months ago

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
        )