Repository navigation
Document Teams SDK reply modes and reorganize messaging docs - #14764
Corina (corinagum) wants to merge 14 commits into
Conversation
Documents the Teams SDK 2.3.0 reply modes, where the context-level reply starts a thread under a top-level message in one-on-one chats by default, and reorganizes the conversation and messaging pages: placement tables and reply mode sections on the threads page, reply examples that send from stored values after a long task instead of calling the app-level reply inside a handler, a single-source quoted replies section, top-level and in-thread terms instead of L1 and L2, and corrected samples and links. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
|
Learn Build status updates of commit 7853dd6: ✅ Validation status: passedFor more details, please refer to the build report. |
…in Python Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
|
Learn Build status updates of commit 100a166: ✅ Validation status: passedFor more details, please refer to the build report. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
|
Learn Build status updates of commit 772c0ad: ✅ Validation status: passedFor more details, please refer to the build report. |
Arup Roy (aroy-ms)
left a comment
There was a problem hiding this comment.
Reviewed the C# doc changes against the code in microsoft/teams.net#734 (head 24192d8). Python and TypeScript are out of scope for this pass. Inline comments below.
reviewed by Github Copilot with Claude Opus 5.5
Github Copilot on behalf of Arup
| ::: zone pivot="teams-sdk-csharp" | ||
| When your agent calls the reply method, the SDK automatically stamps a quoted reply entity referencing the inbound activity. The reply appears as a quoted reply in Teams. | ||
|
|
||
| The reply quotes the inbound activity only when that activity can be quoted, so a reply to a card action or another invoke is sent without a quote. A reply to a reaction quotes the message the user reacted to. Starting in Teams SDK 2.3.0, in a one-on-one chat, the reply also starts a thread under a top-level message by default. The [reply mode](how-to/conversations/agent-chat-threads.md#choose-a-reply-mode) decides whether the quote is added: the thread mode leaves it out, except on a reply that can't be threaded. |
There was a problem hiding this comment.
C#: a reply to a reaction is not quoted. "A reply to a reaction quotes the message the user reacted to" doesn't match teams.net#734. ReplyAsync quotes the inbound Activity.Id and only when it is a plain number (Context.cs L222-233). A messageReaction activity's id is a service id such as f:… (that's how the tests model it, L1864-1867), so in C# a reply to a reaction goes out without a quote. It is still threaded under the reacted message in a chat.
Suggest dropping that sentence, or replacing it with: "A reply to a reaction isn't quoted, but in a chat it starts a thread under the message the user reacted to."
reviewed by Github Copilot with Claude Opus 5.5
Github Copilot on behalf of Arup
There was a problem hiding this comment.
TypeScript has the same issue. reply() decides whether to quote based on the inbound activity's own id, and quotes that id, not replyToId (activity.ts L627-L632). A messageReaction has a service f: ID, so the reply isn't quoted. The microsoft/teams.ts#996 tests model reactions that way and assert only placement. The suggested rewrite works for TypeScript too. To quote the reacted-to message explicitly, use quote(activity.replyToId, ...).
reviewed by Github Copilot with Claude Opus 5.5
Github Copilot on behalf of Arup
There was a problem hiding this comment.
The live service doesn't send that shape. In our captures from Teams (1:1 and group chats, with the TypeScript, Python and .NET SDKs), every messageReaction arrives with a plain numeric id equal to the id of the message that was reacted to. So ReplyAsync / reply() quotes the reacted-to message through activity.id, and the reply rendered with that quote in all three SDKs. The f: id in the unit tests is a fixture choice to exercise the replyToId placement path, not the service's shape. I'll keep the sentence as is but clean up the unit tests to be more clear.
|
|
||
| A reply that starts a thread starts it under the message the incoming activity is about: the user's message, or the message the user reacted to, edited, deleted, or selected a card button on. If that message can't be a thread root, for example a card message whose ID can't be used as a thread root, the reply stays at the top level. For how the SDK decides whether an activity is in a thread, see [Identify the incoming activity's level](#identify-the-incoming-activitys-level). | ||
|
|
||
| When the service rejects a thread reply in a one-on-one chat, the context-level reply method throws the error to your handler and doesn't send the reply at the top level instead. In a channel, if the service returns `404` for the thread reply, the SDK posts to the same thread through the legacy channel threading endpoint. |
There was a problem hiding this comment.
TypeScript: a default ctx.reply to a targeted top-level message might fail. When the inbound message is targeted and top-level in a chat that carries the threading IDs, ctx.reply targets the response and starts a thread under the user's targeted message: /replyChains/{replyChain.id}?isTargetedActivity=true (activity.ts L726-L759, activity-sender.ts L89-L93). microsoft/teams.ts#996 has a unit test for this path. This page's error table says a rootMessageId that identifies a targeted message returns 400 Replies are not allowed for Targeted Messages, and targeted-messages.md says targeted messages don't support replies. Because a rejected chat thread reply throws without a top-level fallback, the response would be lost, where 2.2 sent it at the top level.
Could you confirm the service behavior? If the 400 applies, document it here and in targeted-messages.md (for example, use replyMode: 'quote' or send for targeted prompts), or the SDK should skip threading for targeted inbound messages.
reviewed by Github Copilot with Claude Opus 5.5
Github Copilot on behalf of Arup
There was a problem hiding this comment.
Tested live in a group chat: a user's targeted message arrives with recipient.isTargeted: true and without channelData.replyChain, so none of the SDKs takes the thread path. The default ctx.reply went to POST /v3/conversations/{id}/activities?isTargetedActivity=true and returned 201, posting a private reply at the top level, the same as 2.2. No replyChains request was made, so the 400 Replies are not allowed for Targeted Messages case doesn't come up.
The unit test in [microsoft/teams.ts#996](microsoft/teams.ts#996) uses a targeted payload that also carries replyChain, a shape we haven't seen from the service. If Teams starts sending it, skipping threading for targeted inbound messages would be the fix.
| agenticIdentity: getAgenticIdentity(activity.recipient), | ||
| }; | ||
| await ctx.reply('Working on your trip plan.'); | ||
| startTripPlanning(destination); |
There was a problem hiding this comment.
TypeScript: the sample doesn't compile as written. startTripPlanning isn't declared (TS2304). replyWhenDone is declared but never called, so the sample doesn't show how the stored destination reaches the completion reply. Suggest declaring the placeholder, for example declare function startTripPlanning(destination: ThreadDestination): void;, with a comment that the task calls replyWhenDone(destination) when it finishes. Alternatively, inline a minimal task that calls it.
reviewed by Github Copilot with Claude Opus 5.5
Github Copilot on behalf of Arup
There was a problem hiding this comment.
Generally for code snippets we don't concern ourselves with defining example-oriented methods like startTripPlanning that's intended for showcasing a scenario; here I've just gone ahead and added placeholder definitions & resolved these, but going forward I'm not sure how much value this adds.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Learn Build status updates of commit 4f1b2af: ✅ Validation status: passedFor more details, please refer to the build report. |
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…usings Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
|
Learn Build status updates of commit 5a15886: ✅ Validation status: passed
For more details, please refer to the build report. |
There was a problem hiding this comment.
I'm doing some refactoring that's going to foul this up, I am removing this file and putting its contents elsewhere. Don't invest any more here. When you're finished, let me know and I'll help get things reorganized.
On this topic, I would love your help in the future with activity events, I'm trying to reshape this content around a canonical reference for all of the events, their names, syntax, etc. What we have today is very incomplete.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…thread Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Learn Build status updates of commit c5677f9: ❌ Validation status: errorsPlease follow instructions here which may help to resolve issue.
For more details, please refer to the build report. Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them. |
Documents reply modes in Teams SDK 2.3.0, where
ctx.replystarts a thread under a top-level chat message by default, reorganizes the conversation and messaging pages so send, reply, threads and quotes are easier to follow, and fixes SDK samples and claims on those pages that were incorrect.Note
This PR builds on #14762 (per-call service URLs in TypeScript) and includes its commits. Review only the commits after
810931df6. Once #14762 merges, this PR will contain only those commits. Reply modes ship in Teams SDK 2.3.0, which isn't released yet, so this PR shouldn't merge before that release.Why
In Teams SDK 2.3.0, the context-level reply method (
ctx.reply()/context.ReplyAsync()) follows the recommended agent behavior on the threads page: in a chat, a reply to a top-level message starts a thread under it. The reply mode controls this:combined(default, thread plus quote),thread(thread, no quote) andquote(stays at the level of the incoming message, which matches earlier versions). Several Learn pages described the earlier behavior, including an IMPORTANT note telling developers to call the app-level reply method from inside a handler to reach a thread. That workaround is no longer needed, and reactive replies are the preferred path.Changes by page
Threads in channels and one-on-one agent chats (
agent-chat-threads.md)teamsfor the app object, matching the rest of Learn and the SDK'svar teams = app.UseTeams()setup.Send and receive messages (
build-conversational-capability.md)OnEvent(OnReadReceiptdoesn't exist).editMessage,undeleteMessage,softDeleteMessage).Send proactive messages (
send-proactive-messages.md)conversationParameters, theActivity.ServiceUrlreference link).Other pages
bot-concepts.md: explainsctx.sendversusctx.replywith a link to the reply modes.agent-plans.md: replaced L1 and L2 with "top-level" and "in-thread", and named the app-level reply method in the completion guidance.receiving-sending-messages.md: removed repeated agentic identity guidance, and the proactive samples pass the stored service URL in all three languages.sdk-code-basics.mdandmanage-conversation-state.md: the samples use send in all three languages, so the pivots behave the same in a chat.channel-and-group-conversations.md,targeted-messages.md: small wording, link and naming fixes.Corrected SDK samples and claims
A review of every SDK sample and claim on the touched pages against the TypeScript, Python and .NET SDK source found errors that predate this PR. Fixed:
UpdateActivityAsync/DeleteActivityAsync(the previous calls didn't compile), quote builder samples match their comments, mention samples useTeamsChannelAccountandMentionEntity, andbot-concepts.mdnamesContext<TActivity>,TeamsBotApplicationandOnAdaptiveCardAction.conversationUpdateroute (membersAddedandmembersRemovedaren't routes), undeclaredsendandRecipientcasing are fixed, and mention objects include the requiredrole.KeyError,from_propertyisfrom_, snippets that didn't parse are fixed, and the tag mention setstype="tag".channelDataisn't included in personal conversations.Not changed
streaming-ux.md.Validation
channel-and-group-conversations.md.Microsoft.Teams.Apps, and changed Python snippets parse.