Case Study · 2026

From per-draft approvals to autonomous email drafting.

I migrated a credit-bound, approval-gated AI email assistant into a self-hosted Microsoft 365 architecture — eliminating credit exhaustion and the Slack-approval bottleneck for a California law firm.

Client California law firm
(name on request)
Role Sole contractor — architecture, build, prompt engineering
Timeline Phase 1 · 21 days
Domain Legal / professional services
01 / CONTEXT

An AI assistant that worked — but couldn't scale.

The firm had an existing AI email assistant — internally named Viktor — running inside a Slack channel. It worked: across 34 production runs it processed 350+ emails, classified them accurately, and drafted in the managing attorney's voice using 14 documented behavioral rules.

But the operational model created two friction points the firm couldn't get past:

Friction 01 · Credit exhaustion
Viktor consumed credits per execution and depleted three times in fourteen days, repeatedly halting automation.
Friction 02 · Per-draft approval
Every API action required manual approval inside Slack — creating a bottleneck that prevented rollout to additional attorneys and shared inboxes.

The firm wanted an architecture they owned end-to-end, with predictable cost, no per-draft approval, and a path to deploy across six+ mailboxes.

02 / DISCOVERY

Before writing code, I rebuilt the rulebook.

I spent the first phase observing Viktor in production — analyzing 34 runs and 350+ emails — and extracted a 22-page knowledge document covering every rule, edge case, tone sample, and routing decision the predecessor had accumulated.

This became the source-of-truth for the new system's prompts and routing logic. It also surfaced the categories where the firm wanted AI to never draft — opposing counsel, settlement discussions, court deadlines, IRS notices — high-risk legal communications where wrong wording could waive privilege or create liability.

Artifact
A 22-page knowledge extraction document covering: 14 behavioral rules, 43 tone samples grouped by recipient type, 13 inbound email categories with examples, and a 12-category Never-Auto-Draft list with risk-tiered routing recommendations.
03 / ARCHITECTURE

A two-stage AI pipeline, self-hosted inside the firm's tenant.

I evaluated two paths — Power Automate + Azure OpenAI versus Copilot Studio + Power Automate — and recommended the first. It eliminated the credit model that killed Viktor, kept all data inside the firm's Microsoft tenant, and cost roughly $140/month less to operate.

Inbound mail is fetched every two hours during business hours via Microsoft Graph. Each email runs through a classifier that assigns one of four routes, and only the route requiring a reply hits the drafter. Prompts live in SharePoint so the firm can edit behavior without touching the flow itself.

FETCH CLASSIFY ROUTE ACT Graph API unread inbox Classifier GPT-4o + SharePoint prompt 4-way switch DRAFT REPLY → Drafter (GPT-4o) DRAFT SPAM REPLY → Template insert FLAG + MARK READ → Human review MARK READ ONLY → Silent dismiss Recurrence: every 2h, Mon–Fri, 8a–4p PT · Per-email processing · Conversation dedup via state array

Critical design choices worth calling out:

  • Per-email processing, not batched — sidesteps Graph API mailbox concurrency limits and 408 timeouts.
  • Conversation deduplication via a state array — prevents re-drafting on superseded threads.
  • App-only auth via Azure App Registration — survives password changes and extends cleanly to additional mailboxes.
  • Hardcoded never-draft rules for opposing counsel and other high-risk legal categories — defense-in-depth on top of the classifier.
  • No auto-send, ever — every draft lands in Outlook for attorney review.
04 / OUTCOMES

Predictable cost, autonomous operation, multi-mailbox path.

~$160/mo
All-in operating cost. Pay-per-token Azure OpenAI replaces unpredictable credit drain.
0
Per-draft approval steps. Autonomous classification and drafting; review happens in Outlook.
6+
Mailboxes the architecture supports — attorney inboxes plus shared boxes (intake@, info@, billing@).

Beyond the numbers, the deliverable the firm cares about most is ownership: the flow, the prompts, the templates, and the documentation all live in their tenant and SharePoint. Nothing is locked behind a vendor's credit ledger.

05 / STACK

Built on the Microsoft stack the firm already lives in.

Power Automate (Premium) Orchestration
Azure OpenAI · GPT-4o Classification + drafting
Microsoft Graph API Mailbox read/write
SharePoint Online Prompt + template library
Azure App Registration Client-credentials auth
HTML / CSS templates Signature + spam reply
06 / REFLECTION

What this project taught me.

Most of the value in this engagement wasn't the code — it was the discovery work that translated a working-but-fragile predecessor into a documented set of rules the new system could inherit. The classifier is only as good as the categories you give it, and the drafter is only as good as the tone samples behind it.

The second lesson: in regulated domains, the most important architectural decision is what the AI doesn't do. Opposing counsel, settlement, court deadlines — these never get a draft. Defense-in-depth at the routing layer matters more than prompt cleverness.