Skip to content

Route threaded replies through reply endpoint - #664

Open
Mehak Bindra (MehakBindra) wants to merge 4 commits into
mainfrom
mehakbindra-summarize-shared-page
Open

Route threaded replies through reply endpoint#664
Mehak Bindra (MehakBindra) wants to merge 4 commits into
mainfrom
mehakbindra-summarize-shared-page

Conversation

@MehakBindra

@MehakBindra Mehak Bindra (MehakBindra) commented Aug 31, 2026

Copy link
Copy Markdown
Member

Summary

  • add endpoint-based activity replies at POST /v3/conversations/{conversationId}/activities/{rootId}
  • route proactive and context-derived channel/group thread replies without constructing ;messageid= conversation IDs
  • translate legacy suffixed IDs passed to app.SendAsync() into reply-endpoint calls
  • expose inbound channelData.thread.id and retain legacy suffix parsing as a compatibility fallback
  • separate quoting from placement by standardizing on MessageActivityInput.AddQuote() and deprecating legacy context quote/reply conveniences without removing them
  • update threading and quoting samples

Validation

  • Microsoft.Teams.Core.UnitTests: 170 passed on net8.0 and net10.0
  • Microsoft.Teams.Apps.UnitTests: 535 passed on net8.0 and net10.0
  • updated sample projects build successfully

Separate thread placement from quoted message rendering while retaining compatibility for legacy context APIs and suffixed inbound conversation IDs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7628155d-e8d4-448b-9297-2105dc69c3f5
Copilot AI lite review requested due to automatic review settings August 31, 2026 21:15
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the SDK’s threading model to route threaded replies via the Bot Framework reply endpoint (POST /v3/conversations/{conversationId}/activities/{rootId}) rather than relying on ;messageid=-suffixed conversation IDs, and standardizes quoting via MessageActivityInput.AddQuote() while deprecating legacy convenience helpers.

Changes:

  • Add ConversationClient.ReplyToActivityAsync(...) and route reply calls through the reply endpoint.
  • Expose inbound channelData.thread.id and use it (plus legacy ;messageid= parsing) to determine thread roots for context-derived replies.
  • Update/deprecate quoting/reply convenience APIs and refresh samples/tests accordingly.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/Microsoft.Teams.Core.UnitTests/ConversationClientTests.cs Adds unit coverage for reply-endpoint URL construction and validation.
test/Microsoft.Teams.Apps.UnitTests/TeamsChannelDataDeserializationTests.cs Verifies deserialization of channelData.thread.id.
test/Microsoft.Teams.Apps.UnitTests/TeamsBotApplicationTests.cs Ensures proactive replies use base conversation ID + reply endpoint.
test/Microsoft.Teams.Apps.UnitTests/PromptPreviewTests.cs Adds coverage for context-derived thread-root selection (channel, channelData thread, legacy suffix).
src/Microsoft.Teams.Core/Schema/ConversationExtensions.cs Updates docs and deprecates ToThreadedConversationId.
src/Microsoft.Teams.Core/ConversationClient.cs Introduces ReplyToActivityAsync to call the reply endpoint.
src/Microsoft.Teams.Apps/TeamsBotApplication.cs Routes proactive threaded replies via reply endpoint and validates thread root IDs.
src/Microsoft.Teams.Apps/Schema/TeamsChannelData.cs Adds TeamsChannelDataThread model and TeamsChannelData.Thread.
src/Microsoft.Teams.Apps/Context.cs Deprecates legacy quote/reply conveniences; adds reply-endpoint routing based on inferred thread root.
src/Microsoft.Teams.Apps/Clients/ConversationApiClient.cs Switches reply behavior to use reply endpoint instead of setting ReplyToId.
src/Microsoft.Teams.Apps/Clients/ActivityClient.cs Routes reply methods through ConversationClient.ReplyToActivityAsync.
samples/TargetedMessages/Program.cs Updates sample to use AddQuote(...)+SendAsync(...) rather than ReplyAsync.
samples/M365ExtensionsBot/MyTeamsBot.cs Updates quoting sample to explicit AddQuote usage.
samples/InteractingWithMessagesBot/ThreadingHandlers.cs Demonstrates direct use of reply endpoint and channelData.thread.id fallback.
samples/InteractingWithMessagesBot/README.md Refreshes docs to reflect explicit quoting and reply-endpoint threading.
samples/InteractingWithMessagesBot/QuotingHandlers.cs Updates quoting handlers to use AddQuote + SendAsync.
samples/InteractingWithMessagesBot/Program.cs Updates CLI/help text to match explicit-quote semantics.
Suppressed comments (2)

src/Microsoft.Teams.Apps/TeamsBotApplication.cs:335

  • Reply() strips the conversation ID via conversationId.Split(';')[0], which removes everything after the first ; (not specifically the legacy ;messageid= suffix) and is case-sensitive. Strip only the ;messageid= marker (case-insensitive) and pass that base ID into ReplyToActivityAsync.
        return ConversationClient.ReplyToActivityAsync(
            conversationId.Split(';')[0],
            messageId,

src/Microsoft.Teams.Core/Schema/ConversationExtensions.cs:32

  • This method is now marked obsolete with guidance about legacy ;messageid= suffixes, but it currently strips the base ID by splitting on any ;. Consider stripping only the legacy ;messageid= marker (case-insensitive) so other semicolon-delimited suffixes are preserved.
    [Obsolete("Thread placement is endpoint-based. Use the base conversation ID with ReplyToActivityAsync instead.")]
    public static string ToThreadedConversationId(string conversationId, string messageId)
    {
        if (string.IsNullOrEmpty(conversationId))

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Microsoft.Teams.Apps/TeamsBotApplication.cs
Comment thread src/Microsoft.Teams.Apps/Context.cs Outdated
Comment thread src/Microsoft.Teams.Core/ConversationClient.cs
Comment thread src/Microsoft.Teams.Core/Schema/ConversationExtensions.cs
Route suffixed conversation IDs passed to proactive SendAsync through the reply endpoint so existing callers remain compatible when APX rejects legacy IDs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7628155d-e8d4-448b-9297-2105dc69c3f5
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Keep activity.id set to the root activity targeted by the reply endpoint rather than overwriting it with the created reply ID.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7628155d-e8d4-448b-9297-2105dc69c3f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants