Skip to content

Prompt Preview Support#397

Merged
corinagum merged 17 commits into
microsoft:mainfrom
ShanmathiMayuramKrithivasan:shmayura/prompt-preview
May 11, 2026
Merged

Prompt Preview Support#397
corinagum merged 17 commits into
microsoft:mainfrom
ShanmathiMayuramKrithivasan:shmayura/prompt-preview

Conversation

@ShanmathiMayuramKrithivasan
Copy link
Copy Markdown
Contributor

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 21, 2026 12:53
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 so bots can reference an original targeted message by attaching a targetedMessageInfo entity (with the original message ID) to outgoing activities, enabling Teams to render a collapsible prompt preview.

Changes:

  • Introduces TargetedMessageInfoEntity to the API models and exports it via the entity model surface.
  • Auto-attaches TargetedMessageInfoEntity(message_id=<incoming.id>) in ActivityContext.send() when handling an inbound targeted message (unless already provided by the developer).
  • Adds unit tests and extends the targeted-messages example to demonstrate reactive and proactive usage.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/apps/src/microsoft_teams/apps/routing/activity_context.py Auto-adds targetedMessageInfo entity during send for targeted inbound activities.
packages/apps/tests/test_activity_context.py Adds tests validating auto-population, non-targeted behavior, and no-duplication.
packages/api/src/microsoft_teams/api/models/entity/targeted_message_info_entity.py Defines the new entity model with type and message_id.
packages/api/src/microsoft_teams/api/models/entity/entity.py Extends the Entity union to include TargetedMessageInfoEntity.
packages/api/src/microsoft_teams/api/models/entity/init.py Exports TargetedMessageInfoEntity from the entity package.
packages/api/tests/unit/test_targeted_message_info_entity.py Adds unit tests for default type, field behavior, and camelCase serialization.
examples/targeted-messages/src/main.py Adds example commands demonstrating prompt preview usage (reactive/proactive).

Comment thread packages/apps/src/microsoft_teams/apps/routing/activity_context.py Outdated
Comment thread packages/apps/src/microsoft_teams/apps/routing/activity_context.py Outdated
Comment thread examples/targeted-messages/src/main.py Outdated
Comment thread packages/apps/tests/test_activity_context.py Outdated
Comment thread packages/apps/src/microsoft_teams/apps/routing/activity_context.py Outdated
Comment thread packages/apps/src/microsoft_teams/apps/routing/activity_context.py Outdated
@lilyydu
Copy link
Copy Markdown
Collaborator

lilyydu commented Apr 21, 2026

also curious, what does the UI look like for this?

Comment thread packages/apps/src/microsoft_teams/apps/routing/activity_context.py Outdated
Comment thread examples/targeted-messages/src/main.py Outdated
@ShanmathiMayuramKrithivasan
Copy link
Copy Markdown
Contributor Author

also curious, what does the UI look like for this?

image

@corinagum corinagum merged commit d2433bd into microsoft:main May 11, 2026
4 checks passed
corinagum added a commit that referenced this pull request May 14, 2026
## Summary

Brings `main` into `release` for the 2.0.11 release, with quoted-replies
(PR #321) excluded. Also bumps `version.json` from `2.0.0` to `2.0.11`
to align with the teams.ts release cadence.

Single squashed commit.

> **Branch name note**: the branch is `cg/prep-release-2.0.1` (left over
from an earlier draft when alignment hadn't been decided yet). The
actual published version per `version.json` is **2.0.11**.

## What's in this release

- All commits merged to main since 2.0.0 (the previous release),
notably:
  - **Reactions GA** (PR #427) — `@experimental` removed; sample fixed
  - Prompt Preview Support (PR #397)
  - Various dependency bumps and bug fixes

## What's NOT in this release

**Quoted-replies feature (PR #321) is excluded:**
- `prepend_quote()`, `add_quote()` builder methods — absent
- `ctx.quote()` and quote-aware `ctx.reply()` behavior — reverted to
legacy `reply_to_id` + blockquote
- `examples/quoting` — removed
- QR-related tests — removed

**Kept intentionally:**
- `QuotedReplyEntity` and `QuotedReplyData` types stay in the `Entity`
union so inbound activities carrying `quotedReply` entities still parse
- `add_targeted_message_info` runtime strip-QR logic — preserves
prompt-preview cleanup

## Version

`version.json`: `2.0.0` → `2.0.11`

This one-time jump aligns teams.py with teams.ts. Going forward, both
progress on a shared 2.0.x patch cadence.

## Test plan

- [x] `uv run ruff check` — all checks passed
- [x] `uv run pyright` — 0 errors, 0 warnings
- [x] `uv run pytest` — 571/571 tests
- [x] `uv build --all-packages` — wheels produced; consumer install
verified (fresh venv, `pip install --no-index --find-links` succeeds,
`QuotedReplyEntity` importable, `prepend_quote`/`add_quote` absent,
`add_targeted_message_info` present)
- [ ] ADO Public publish pipeline (post-merge)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

4 participants