From mypos-legal-copilot
Send the lawyer-reviewed AI draft, file the final email + new documents to SharePoint via the n8n Legal Copilot workflow, and transition the ticket to Done.
How this command is triggered — by the user, by Claude, or both
Slash command
/mypos-legal-copilot:reply-and-close <TICKET-KEY> [--dry-run]The summary Claude sees in its command listing — used to decide when to auto-load this command
# /reply-and-close After the lawyer has reviewed (and optionally edited) the AI draft in their Outlook AI Drafts folder, this command: 1. Sends the draft (now reviewed and edited by the lawyer) 2. Files the sent email + any new documents to SharePoint via the n8n `Legal Copilot` workflow 3. Captures any lawyer edits as a feedback entry appended to the shared memory file 4. Transitions the Jira ticket to Done **This is the only command that sends emails. Every other command stops at "draft created."** ## Constants - Atlassian Cloud ID: `fb47470f-f5c2-44bc-8182-f2a22f059adb` - n8n workfl...
After the lawyer has reviewed (and optionally edited) the AI draft in their Outlook AI Drafts folder, this command:
Legal Copilot workflowThis is the only command that sends emails. Every other command stops at "draft created."
fb47470f-f5c2-44bc-8182-f2a22f059adbVAKq9Bra0RA0SdCOhttps://myposai.app.n8n.cloud/webhook/legal-copilot-filing$ARGUMENTS:
<TICKET-KEY> (required) -- e.g., LEGAL-4321--dry-run (optional) -- show what would happen without sending or transitioningSearch the user's Outlook AI Drafts folder for a draft tagged with the ticket key. The /triage command tags drafts with a custom property x-mypos-legal-ticket: <TICKET-KEY>.
mcp__microsoft-365__outlook_email_search filtered to:
AI Draftsx-mypos-legal-ticket eq '<TICKET-KEY>'If no draft is found, ask the user:
No AI draft found for {ticket_key} in your AI Drafts folder.
Possible reasons:
(a) The ticket hasn't been triaged yet -- run /triage {key} first.
(b) You moved or renamed the draft -- paste the message ID or paste the draft content here.
(c) Another lawyer triaged it on their machine -- the draft is in their AI Drafts, not yours.
If multiple drafts found (e.g., re-triaged multiple times), pick the most recent and warn the user.
Get the draft body, subject, and recipient list. Compare against what /triage originally produced (parse the AI Triage Jira comment for the original draft text).
Detect lawyer edits:
| Comparison | Disposition |
|---|---|
| Identical | No edits captured. Continue. |
| Whitespace/formatting only | No edits captured. Continue. |
| Material changes | Capture as feedback in Step 6 below. |
Show the lawyer:
About to send this email and close {ticket_key}.
To: {recipient list}
Subject: {final subject}
Body preview:
{first 300 chars of body}
Attachments: {count} files
Material edits since AI draft: {yes/no}
Confirm? (y / n / show-full-body)
If --dry-run, print the above and stop without sending. Otherwise wait for explicit y.
mcp__microsoft-365__outlook_email_send -- sends the draft, removes it from AI Drafts, places the sent copy in the user's Sent Items.
Capture the sent message ID for filing.
Invoke the sharepoint-filer skill (n8n-backed -- see skills/sharepoint-filer/SKILL.md) with:
ticket_keyticket_summary (for filenames)matter_type (from the AI Triage Jira comment)files:
.eml (download via M365 MCP, encode as base64 with mime_type: message/rfc822, role: final_email)/triage ran (skip ones already filed -- list the case folder via mcp__microsoft-365__sharepoint_list_items first)memory_notes -- a brief markdown block summarising:
triage_metadata -- pass through the metadata from the AI Triage commentThe skill calls the n8n workflow which uploads the .eml to myPOS Legal/{matter_folder}/{ticket_key}/ and appends a ## Case: {ticket_key} close-out entry to legal_copilot_memory.md.
If the workflow returns success: false, halt before transitioning the ticket to Done. Surface the error and let the lawyer retry.
Capture the returned sharepoint_folder_url, documents_filed[].sharepoint_url, and memory_file_url for use in Step 7.
If material edits were detected in Step 2, the memory_notes block from Step 5 should already include a structured feedback section. Make sure it has:
### Lawyer feedback ({ticket_key})
**Skill used:** {legal-triage-* skill, from AI Triage comment}
**AI draft excerpt:** "{first material-changed sentence as written by AI}"
**Lawyer changed to:** "{first material-changed sentence as sent}"
**Category:** {best guess: factual correction | tone | scope | jurisdiction-specific | other}
**Captured by:** /reply-and-close
The n8n workflow appends this to myPOS Legal/Claude skills memory/Copilot/_knowledge/legal_copilot_memory.md under the case entry. The next /triage-board run will read this back from SharePoint and surface emerging patterns.
This gap (AI draft vs. what the lawyer actually sent) is the highest-signal training data we have.
Post a final comment on the ticket:
**Reply sent and ticket closed**
Sent to: {recipient list}
Filed to SharePoint: [{matter_type}/{ticket_key}/]({sharepoint_folder_url})
- Final email: [{final.eml}]({sharepoint_url_of_final_eml})
- {N} new attachments (if any)
{if material edits: "Lawyer-edited draft -- {summary of edits} -- captured to memory file."}
Memory file: [legal_copilot_memory.md]({memory_file_url})
*Closed by Legal Copilot via n8n workflow VAKq9Bra0RA0SdCO.*
Then transition to Done:
mcp__atlassian__getTransitionsForJiraIssue to find the Done transition ID.mcp__atlassian__transitionJiraIssue to apply it.Replied and closed {ticket_key}:
Sent: ✓ to {recipient list}
Filed to SharePoint: {sharepoint_folder_url} (final email + {N} new attachments)
Memory file updated: {memory_file_url}
Jira: transitioned to Done
{if edits captured: "Lawyer edits captured ({category}) -- will improve future drafts after the next /triage-board run"}
y confirmation in Step 3 (unless --dry-run, which doesn't send)./triage flagged human_review_required = true, refuse to send and ask the user to confirm they've reviewed the flag.risk gates triggered unless the lawyer has explicitly added a comment acknowledging the risk and approving the send. Look for a comment with text like approved for send or risk reviewed from the lawyer in the last hour.success: false, do not transition -- the audit trail must be complete on SharePoint before the ticket closes.npx claudepluginhub mypostech/mps-legal-legalcopilot-ai