When to Use
- When drafting a chat body in Teams desktop
- When Teams Web / Playwright / CDP cannot be used and the authenticated desktop app is used
- When verifying the recipient and body and stopping to wait for the user's final send
Do not use: meeting participation, calls, channel posts, file sharing, editing or deleting after a message is sent.
Safety Contract
- Do not send. Stop on the screen where the recipient and body have been entered, and have the user themselves press the final send button.
- Do not determine the recipient by display name alone; match against an email address confirmed via the organizational directory or similar.
- Confirm the recipient and expected account via the Teams window title. If there are 0 or multiple candidates, stop.
- If an existing draft has different content, do not overwrite it. If the body is identical, treat it as success without re-entering.
SendKeys, the send button's click /InvokePattern, do not perform coordinate clicks.- If authentication, MFA, or account switching is required, indicate the target and completion marker and hand off to the user.
Workflow
- Confirm the recipient's display name, internal email address, expected Teams account, and body.
- Check whether Teams is running. If necessary, use the helper's
Opento open the target chat. Since this operation may bring Teams to the foreground, notify the user before executing it. Inspectto check the window title, composer, existing draft, and send button.Draftto enter the body. If there is a different existing draft, stop.ready-for-user-send、DraftMatches=true、SendEnabled=true、SendActionPerformed=false.- If necessary,
-ScreenshotPathto save the current screen, ask the user to perform the send operation, and stop.
Commands
PowerShell 7 (pwsh).
$script = '<skill-dir>/scripts/Set-TeamsDesktopDraft.ps1'
& $script -Mode Open `
-RecipientDisplayName '<display-name>' `
-RecipientEmail '<user@example.com>' `
-ExpectedAccount '<signed-in-account@example.com>'
& $script -Mode Inspect `
-RecipientDisplayName '<display-name>' `
-RecipientEmail '<user@example.com>' `
-ExpectedAccount '<signed-in-account@example.com>'
& $script -Mode Draft `
-RecipientDisplayName '<display-name>' `
-RecipientEmail '<user@example.com>' `
-ExpectedAccount '<signed-in-account@example.com>' `
-Message '<message>' `
-ScreenshotPath 'output/teams-draft.png'
Failure Handling
OpenIf the target title still does not appear afterDraftdo not repeatedly press the sameInspectonce.- If UIA does not expose the composer, stop as unverified. Do not automatically fall back to the web version or restart the app.
DraftIf the result ofInspectto read the current value and check whether the body is identical.- Bringing the app to the foreground, focusing the input field, and operating the send button are not included in the completion conditions.
Validation
& <skill-dir>/scripts/Test-TeamsDesktopDraft.ps1
For real-device testing, so as not to break existing chats,Inspect first.Draft only when the body to actually show the user has been finalized.
Done Criteria
- The target display name and expected account match in the window title
- The composer's draft exactly matches the requested body
- The send button exists and is enabled
SendActionPerformed=falseto finish- Explicitly tell the user "Please press the send button" and stop