Skip to content

Prompt Preview Support#433

Open
ShanmathiMayuramKrithivasan wants to merge 2 commits intomicrosoft:mainfrom
ShanmathiMayuramKrithivasan:shmayura/prompt-preview
Open

Prompt Preview Support#433
ShanmathiMayuramKrithivasan wants to merge 2 commits intomicrosoft:mainfrom
ShanmathiMayuramKrithivasan:shmayura/prompt-preview

Conversation

@ShanmathiMayuramKrithivasan
Copy link
Copy Markdown
Collaborator

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.

Copilot AI review requested due to automatic review settings April 20, 2026 13:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 TargetedMessageInfoEntity and updated entity JSON conversion to support round-tripping it.
  • Auto-insert targetedMessageInfo into 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.

Comment thread Libraries/Microsoft.Teams.Apps/Contexts/Context.Send.cs
Comment thread Libraries/Microsoft.Teams.Apps/Contexts/Context.Send.cs Outdated
Comment thread Samples/Samples.TargetedMessages/Program.cs
// 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)
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.

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)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.


namespace Microsoft.Teams.Api.Entities;

public class TargetedMessageInfoEntity : Entity
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.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Copy Markdown
Contributor

@corinagum corinagum left a comment

Choose a reason for hiding this comment

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

  • 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?

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.

3 participants