Skip to content

feat(msteams): implement sendPayload for interactive approval cards#2480

Open
BingqingLyu wants to merge 4 commits into
mainfrom
fork-pr-66327-feat-msteams-sendpayload-approval-cards
Open

feat(msteams): implement sendPayload for interactive approval cards#2480
BingqingLyu wants to merge 4 commits into
mainfrom
fork-pr-66327-feat-msteams-sendpayload-approval-cards

Conversation

@BingqingLyu

@BingqingLyu BingqingLyu commented Apr 28, 2026

Copy link
Copy Markdown
Owner

Summary

Implements sendPayload for the MS Teams channel extension so approval prompts render as Adaptive Cards with clickable buttons instead of plain text with raw /approve commands.

Closes openclaw#64690

Problem

The Teams outbound adapter only implemented sendText, sendMedia, and sendPoll. The delivery pipeline checks handler.sendPayload && hasReplyPayloadContent(...) before dispatching interactive payloads — since Teams had no sendPayload, all approval prompts fell through to sendText, rendering as:

Reply /approve abc123 yes to approve

Solution

Added sendPayload to the Teams outbound adapter following the patterns established by Slack, Discord, and Telegram:

  1. extensions/msteams/src/outbound.ts:

    • Added buildApprovalAdaptiveCard() helper that maps interactive button blocks to Adaptive Card Action.Submit buttons
    • Uses messageBack (not imBack) to avoid echoing raw approval tokens — matches the existing poll card pattern in polls.ts
    • Honors pre-built channelData.msteams.card if supplied
    • Uses resolveInteractiveTextFallback() to derive card body text from text blocks
    • Sends media first via sendPayloadMediaSequenceAndFinalize, then finalizes with the card
    • Falls back to sendTextMediaPayload when no interactive buttons are present
  2. extensions/msteams/src/channel.ts:

    • Wired sendPayload directly on the outbound config (since createRuntimeOutboundDelegates only supports sendText/sendMedia/sendPoll), following the Slack channel pattern

Result: Approval prompts render as Adaptive Cards with "Approve" / "Deny" buttons. Clicking a button sends the /approve command via messageBack.

Testing

  • 3 new test cases in outbound.test.ts:
    • Interactive buttons → Adaptive Card with messageBack actions
    • No buttons → falls back to sendText
    • Pre-built channelData card → sent directly
  • All 66 Teams extension test files pass (860 tests)
  • Run: pnpm test:extension msteams

AI Disclosure

  • AI-assisted (GitHub Copilot CLI)
  • Fully tested — pnpm test:extension msteams passes (860/860 tests)
  • I understand what the code does
  • I work at Microsoft and can verify this against a real Teams tenant

JT Turek (Federal) and others added 4 commits April 13, 2026 23:59
Add sendPayload to the MS Teams outbound adapter so approval prompts
render as Adaptive Cards with clickable buttons instead of plain text.

Implementation:
- Map interactive button blocks to Adaptive Card Action.Submit buttons
  using messageBack (hidden value + friendly displayText), matching
  the existing poll card pattern
- Honor pre-built channelData.msteams.card if supplied
- Send media first via sendPayloadMediaSequenceAndFinalize, then
  finalize with the Adaptive Card
- Fall back to sendText when no interactive buttons are present
- Resolve text via resolveInteractiveTextFallback for text-only blocks
- Wire sendPayload in channel.ts alongside createRuntimeOutboundDelegates

Closes openclaw#64690

Co-authored-by: Copilot <[email protected]>
@BingqingLyu BingqingLyu added conflicting-group-1 Conflicting PR group 1 — review as a batch conflicting-pr Shares at least one cross-PR dependency with other PRs labels May 26, 2026
@BingqingLyu

Copy link
Copy Markdown
Owner Author

⚠️ Cross-PR Conflict Detected

This PR shares modified code with #2465.

Shared functions:

Function File Also modified by
describeMSTeamsMessageTool extensions/msteams/src/channel.ts #2465

Recommendation: Coordinate with #2465 before merging.


Auto-detected by codegraph — a code graph analysis tool built on neug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicting-group-1 Conflicting PR group 1 — review as a batch conflicting-pr Shares at least one cross-PR dependency with other PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Teams channel: implement sendPayload for interactive approval cards

1 participant