Route threaded replies through reply endpoint - #664
Open
Mehak Bindra (MehakBindra) wants to merge 4 commits into
Open
Route threaded replies through reply endpoint#664Mehak Bindra (MehakBindra) wants to merge 4 commits into
Mehak Bindra (MehakBindra) wants to merge 4 commits into
Conversation
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
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Copilot started reviewing on behalf of
Mehak Bindra (MehakBindra)
August 31, 2026 21:16
View session
Contributor
There was a problem hiding this comment.
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.idand 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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /v3/conversations/{conversationId}/activities/{rootId};messageid=conversation IDsapp.SendAsync()into reply-endpoint callschannelData.thread.idand retain legacy suffix parsing as a compatibility fallbackMessageActivityInput.AddQuote()and deprecating legacy context quote/reply conveniences without removing themValidation
Microsoft.Teams.Core.UnitTests: 170 passed on net8.0 and net10.0Microsoft.Teams.Apps.UnitTests: 535 passed on net8.0 and net10.0