Prompt Preview Support#433
Prompt Preview Support#433ShanmathiMayuramKrithivasan wants to merge 4 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds “prompt preview” support for targeted-message replies by introducing a targetedMessageInfo entity (carrying the original messageId), wiring it into entity (de)serialization, and auto-populating it during reactive sends.
Changes:
- Added
TargetedMessageInfoEntityand updated entity JSON conversion to support round-tripping it. - Auto-insert
targetedMessageInfointo outgoing activities when the inbound activity is targeted (reactive prompt preview). - Added tests plus a sample update demonstrating reactive and “proactive/manual” usage.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/Microsoft.Teams.Apps.Tests/Activities/PromptPreviewTests.cs | New tests validating auto-population behavior and non-duplication. |
| Tests/Microsoft.Teams.Api.Tests/Json/Entities/TargetedMessageInfoEntity.json | Golden JSON fixture for entity serialization tests. |
| Tests/Microsoft.Teams.Api.Tests/Entities/TargetedMessageInfoEntityTests.cs | Serialization/deserialization coverage for the new entity (direct + derived/base). |
| Samples/Samples.TargetedMessages/Program.cs | Adds sample commands for prompt preview scenarios. |
| Libraries/Microsoft.Teams.Apps/Contexts/Context.Send.cs | Auto-populates targetedMessageInfo in outgoing activities for targeted inbound flows. |
| Libraries/Microsoft.Teams.Api/Entities/TargetedMessageInfoEntity.cs | New entity model for prompt preview messageId. |
| Libraries/Microsoft.Teams.Api/Entities/Entity.cs | Registers the new entity type in the entity JSON converter read/write paths. |
| Libraries/Microsoft.Teams.Api/Account.cs | Ensures isTargeted can be deserialized by STJ via [JsonInclude]. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
corinagum
left a comment
There was a problem hiding this comment.
- Is quoted reply and prompt preview stacking the intended UX? What should this look like?
- Has it been tested? How can we test this out?
| { | ||
| // Auto-populate targetedMessageInfo entity for prompt preview | ||
| // when the incoming activity was a targeted message (reactive flow). | ||
| #pragma warning disable ExperimentalTeamsTargeted | ||
| if (activity is MessageActivity && Activity.Recipient?.IsTargeted == true && Activity.Id is not null) | ||
| { | ||
| var hasEntity = activity.Entities?.Any(e => e is TargetedMessageInfoEntity) ?? false; | ||
| if (!hasEntity) | ||
| { | ||
| activity.Entities ??= []; | ||
| activity.Entities.Add(new TargetedMessageInfoEntity { MessageId = Activity.Id }); | ||
| } | ||
| } | ||
| #pragma warning restore ExperimentalTeamsTargeted |
There was a problem hiding this comment.
Also scan activity.Entities for any entity whose wire type equals "quotedReply" targeting Activity.Id, and scan activity.Text for a matching <quoted messageId="<tm-id>"/> placeholder. If either is found, strip both and log. Per §6.1 of the prompt preview design, PP owns the preview surface for targeted message flows and qtdMsgs must not be set. Matching on the string "quotedReply" avoids taking a dependency on the quoted replies PR, which has not landed on main.
There was a problem hiding this comment.
Fixed, but from the other direction - Reply skips ToQuoteReply when the incoming activity is targeted, so the blockquote is never generated. Same outcome. Since quoted reply is still not fully rolled out, going with this approach for the fix.
There was a problem hiding this comment.
Not a fan of this approach. I intentionally asked for the check to be for quotedReply here to avoid collision with the quoted replies sdk changes, and we don't know which order they will be merged in.
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace Microsoft.Teams.Api.Entities; | ||
|
|
There was a problem hiding this comment.
A parallel AddTargetedMessageInfo(string messageId) on Activity would match AddFeedback / AddCitation and the TS addTargetedMessageInfo already in this PR. Gives a single home for the §1 P0 "one PP per message" dedup plus the usage XML doc.
There was a problem hiding this comment.
Updated.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Prompt preview allows a bot to reference the original targeted message in its reply, so Teams can render a collapsible preview of the user's prompt.
When a bot replies to a targeted message (reactive scenarios), the SDK now passes the original message's messageId via a targetedMessageInfo entity in the activity's entities array.
For proactive replies, developers can attach the entity themselves with the messageId of the targeted message.