Office 365 Add-In
CaseSolo's Office add-in gives Word and Outlook users tenant-scoped case search, matter-context insertion, demand-letter drafting, client update drafting, opposing-counsel drafting, and insert activity logging.
Runtime Surfaces
src/lib/marketplace/office-addin.tsdefines Office manifest metadata, Word/Outlook capabilities, and the generated XML manifest.src/app/api/office-addin/manifest/route.tsserves the generated Office manifest for sideload or Microsoft 365 admin deployment.src/app/office-taskpane/page.tsxis the production taskpane loaded inside Word and Outlook.src/app/api/office-addin/context/route.tsprovides authenticated case search, context loading, draft generation, and insertion logging.src/lib/integrations/office-addin-context.tsconverts case records into insertable fields, snippets, and deterministic drafts.src/app/(dashboard)/integrations/office-addin/page.tsxlets firm admins download the manifest and configure enabled insertable fields.
Auth And Tenant Safety
Every context API request uses getCurrentUser(request.headers). Case search and context loading always include firmId: ctx.firmId; direct case loads use case.findFirst({ where: { id, firmId } }).
The add-in does not expose raw provider credentials or OAuth tokens. Office insertion actions only receive normalized case context for the authenticated firm.
API Contract
GET /api/office-addin/context?search=...&limit=5
- Returns search results for the authenticated firm.
- Searches case number, incident description, client name, email, and phone.
- Also returns the configured
enabledFields.
GET /api/office-addin/context?caseId=...
- Returns a full normalized
contextpayload for one tenant-scoped case. - Includes enabled insertable fields, matter snippets, recent documents, open tasks, treatment snapshot, and deterministic draft bundle.
POST /api/office-addin/context
action=draft: requirescaseIdanddraftType.- Supported
draftType:matter_summary,demand_letter,client_update_email,opposing_counsel_email. - Creates
office_addin.draft_generatedcase activity. action=log_insert: logsoffice_addin.content_insertedwhen taskpane content is inserted into Word, Outlook, or copied from browser preview.
Drafting Model
The launch implementation is deterministic and case-record driven. It does not call an external AI model, so it is safe for local tests and predictable for attorney review. Drafts are assembled from:
- Case number, status, type, incident details, and SOL date.
- Client contact details.
- Lead attorney and opposing party.
- Insurance carrier and adjuster details.
- Medical record and medical bill summaries.
- Recent documents, open tasks, activity, and negotiation records.
If source data is missing, the draft states the review gap instead of inserting demo names or fake facts.
Office Insertion
The taskpane attempts insertion in this order:
- Word:
Word.run()andcontext.document.getSelection().insertText(text, 'Replace'). - Outlook:
Office.context.mailbox.item.body.setSelectedDataAsync(...). - Browser preview fallback: clipboard copy.
Verification
Targeted coverage:
src/__tests__/lib/office-addin-context.test.tssrc/__tests__/api/office-addin-context.test.ts
Recommended local gates:
npm run test:run -- office-addin-context
npx eslint src/lib/integrations/office-addin-context.ts src/app/api/office-addin/context/route.ts src/app/office-taskpane/page.tsx 'src/app/(dashboard)/integrations/office-addin/page.tsx' src/lib/marketplace/office-addin.ts src/__tests__/lib/office-addin-context.test.ts src/__tests__/api/office-addin-context.test.ts
npm run typecheck