Skip to content

Prompt Preview Support#433

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

Prompt Preview Support#433
ShanmathiMayuramKrithivasan wants to merge 4 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 Outdated
Comment thread Libraries/Microsoft.Teams.Apps/Contexts/Context.Send.cs Outdated
Comment thread Libraries/Microsoft.Teams.Api/Entities/TargetedMessageInfoEntity.cs
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?

Comment on lines 70 to +83
{
// 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
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.

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.

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, 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.

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.

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;

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.

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.

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.

Updated.

Copilot AI review requested due to automatic review settings April 22, 2026 04:02
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

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.

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