Prompt Preview Support#433
Prompt Preview Support#433ShanmathiMayuramKrithivasan wants to merge 2 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.
| // Auto-populate targetedMessageInfo entity for prompt preview | ||
| // when the incoming activity was a targeted message (reactive flow). | ||
| #pragma warning disable ExperimentalTeamsTargeted | ||
| if (Activity.Recipient?.IsTargeted == true && Activity.Id is not null) |
There was a problem hiding this comment.
The guard is inside the generic Send<T> where T : IActivity, so this fires for every activity type — TypingActivity, EndOfConversationActivity, etc. — not just messages. APX only consumes targetedMessageInfo inside MessageEncoder (gated on EnablePromptPreview), so non-message sends during a targeted session will carry a stray entity that APX silently ignores.
Not a correctness bug, but wasted payload + log noise. Consider narrowing the guard:
if (activity is MessageActivity && Activity.Recipient?.IsTargeted == true && Activity.Id is not null)There was a problem hiding this comment.
Fixed.
|
|
||
| namespace Microsoft.Teams.Api.Entities; | ||
|
|
||
| public class TargetedMessageInfoEntity : Entity |
There was a problem hiding this comment.
This new entity depends on Account.IsTargeted, which is marked [Experimental("ExperimentalTeamsTargeted")] (Account.cs:40). Other Targeted-Message surfaces carry the same attribute — ActivityClient.cs:103,128,151, MessageActivity.cs:155, Activity.cs:234. The auto-populate call site in Context.Send.cs wraps the usage in #pragma warning disable ExperimentalTeamsTargeted, which itself indicates the feature is still experimental.
For consistency with the rest of the Targeted-Message API surface, consider marking the class (and/or MessageId) [Experimental("ExperimentalTeamsTargeted")] so consumers opt in explicitly until the feature stabilizes.
There was a problem hiding this comment.
Fixed.
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?
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.