Default targeted replies for targeted inbound messages#439
Merged
heyitsaamir merged 4 commits intoMay 26, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Apps routing layer so that ActivityContext.send() and ActivityContext.reply() automatically send targeted (private) outbound messages when the inbound Teams message was targeted, aligning behavior with the TypeScript SDK and reducing the need for app authors to manually set with_recipient(..., is_targeted=True) in common “private command” flows.
Changes:
- Add targeted-recipient inference in
ActivityContext.send()/reply()for targeted inbound messages, scoped to the same conversation and only when the outbound message doesn’t already specify a recipient. - Model targeted reply metadata with new typed entities (
QuotedReplyEntity,TargetedMessageInfoEntity) and use them when preparing targeted outbound messages. - Expand unit tests and update the
examples/targeted-messagessample + README with “send public/private” commands demonstrating opt-out behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/apps/src/microsoft_teams/apps/routing/activity_context.py | Implements auto-targeting rules for outbound messages based on targeted inbound messages, plus targeted metadata handling. |
| packages/apps/tests/test_activity_context.py | Adds/updates tests covering default targeted behavior, opt-out public sends, cross-conversation behavior, and quoted-reply stripping. |
| packages/api/src/microsoft_teams/api/models/entity/targeted_message_info_entity.py | Introduces a typed entity model for targetedMessageInfo. |
| packages/api/src/microsoft_teams/api/models/entity/quoted_reply_entity.py | Introduces a typed entity model for quotedReply. |
| packages/api/src/microsoft_teams/api/models/entity/entity.py | Registers the new entity types in the Entity union. |
| packages/api/src/microsoft_teams/api/models/entity/init.py | Re-exports the new entity types for public API access. |
| examples/targeted-messages/src/main.py | Updates the sample to demonstrate default-private targeted replies and explicit public opt-out. |
| examples/targeted-messages/README.md | Documents the new default behavior and the new example commands. |
# Conflicts: # examples/targeted-messages/README.md # examples/targeted-messages/src/main.py # packages/api/src/microsoft_teams/api/models/entity/__init__.py # packages/api/src/microsoft_teams/api/models/entity/quoted_reply_entity.py # packages/api/src/microsoft_teams/api/models/entity/targeted_message_info_entity.py # packages/apps/src/microsoft_teams/apps/routing/activity_context.py # packages/apps/tests/test_activity_context.py
corinagum
reviewed
May 26, 2026
corinagum
reviewed
May 26, 2026
corinagum
approved these changes
May 26, 2026
lilyydu
reviewed
May 26, 2026
lilyydu
reviewed
May 26, 2026
7 tasks
corinagum
added a commit
that referenced
this pull request
May 27, 2026
## Summary Brings `origin/main` into `release` for the **2.0.12** release. **No carve-outs this time** — Quoted Replies (PR #321) is included. `version.json`: `2.0.11` → `2.0.12`. Aligns with teams.ts/teams.net cadence. ## What's in this release (delta from 2.0.11) **Features** - Quoted Replies & new quotes features (#321) — previously held back - SuggestedActionSubmitActivity for `suggestedAction/submit` invoke (#434) - Default targeted replies for targeted inbound messages (#439) - Reactions API marked GA (#427) — already shipped in 2.0.11 actually, ignore if duplicate - Prompt Preview support (#397) - Sample: opt targeted-messages into slash commands (#430) - Sample: a2a-in-teams (#401) - Sample: proactive message update (#405) - Allow custom HTTP client via `AppOptions` (#416) **Security & fixes** - Lock JsonWebToken trust-boundary contract (#432) - Bump starlette 1.0.0 -> 1.1.0 for PYSEC-2026-161 / BadHost (#441) - warn when bot starts without credentials (#435) - fix(apps): support AAD v1 issuers in Entra token validation (#422) - fix(apps): log inbound activities at info, warn on missing Authorization (#425) - fix(http-stream): wait for in-flight flush before sending final close (#419) - Mark reactions API as GA and fix sample remove flow (#427) - Revert serviceUrl allowlist (ADO 5310460) (#415) - Route `app.get_app_graph` + `ctx.*_graph` to sovereign endpoints via `cloud.graph_scope` (#402) **Deprecations / package changes** - Remove ai, openai, mcpplugin, a2a, and devtools packages (#413) - Restore and deprecate devtools package (#410) - Deprecate ai, openai, mcpplugin, a2a packages (#406) - Add agent framework example, remove chatprompt/mcp client samples (#386) **Dependency bumps** - urllib3 2.6.3 → 2.7.0 (#426) - python-multipart 0.0.26 → 0.0.27 (#424) - microsoft-kiota-http 1.9.7 → 1.9.9 (#423) - idna 3.11 → 3.15 (#431) - starlette 1.0.0 → 1.1.0 (#441, security) - /examples/tab/Web: qs, postcss, uuid, follow-redirects bumps ## Quoted Replies inclusion notes - Teams client rendering is in-sync with the wire format as of 2026-05-06. - APX QR rollout completed: Public 2026-04-10, GCCH/DoD/Gallatin 2026-04-14. - Builder methods (`prepend_quote()`, `add_quote()`), `ctx.quote()`, and the quote-aware `ctx.reply()` behavior are all present in this release. - `examples/quoting` is included. ## Conflict resolution The 2.0.11 release branch had the QR-removed shape for four files; took `main`'s (QR-included) version for all of them: - `examples/targeted-messages/src/main.py` - `packages/api/src/microsoft_teams/api/activities/message/message.py` - `packages/apps/src/microsoft_teams/apps/routing/activity_context.py` - `packages/apps/tests/test_activity_context.py` `version.json` conflict resolved to `2.0.12`. ## Test plan - [x] `uv sync` clean - [x] `poe check` (ruff format + lint) — clean - [x] `poe test` — 609 passed - [x] `pyright` — 0 errors, 0 warnings - [ ] Pipeline build + test stages green on `release` after merge - [ ] Publish pipeline run with **Public** → ESRP approval → PyPI - [ ] `pip install microsoft-teams-apps==2.0.12` smoke install --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Aamir Jawaid <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]> Co-authored-by: Shanmathi Mayuram Krithivasan <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make
ctx.send()andctx.reply()stay private by default when the inbound Teams message was targeted.Why
This matches the TS SDK behavior and saves app authors from manually wiring
with_recipient(..., is_targeted=True)for the common private slash-command response path.Interesting bits
quotedReplyandtargetedMessageInfoentities so the targeted reply metadata is modeled instead of shoved in as dict soup.send private/send publiccommands.Tips for reviewers
Start with
packages/apps/src/microsoft_teams/apps/routing/activity_context.py, then the new tests inpackages/apps/tests/test_activity_context.py.Test plan