80%
Reduction in manual email processing time per matter
<60s
End-to-end summarization — email received to Case Note created
0 hrs
Manual case note creation per week — was 15+ hours
100%
PDF and DOCX attachment coverage — every file extracted and stored
Faster matter documentation from first email to structured Case Note
0
Silent integration failures — every error captured in Error Log with type, source, and timestamp
Industry
Legal Tech
Region
United States
Client Type
Mid-Market Law Firm Platform
Volume
High email & document volume per matter
Platform
Salesforce Service Cloud + OpenAI GPT + AWS
Delivery Timeline
10 Weeks
80%
Reduction in manual email processing time per matter across all active cases
<60s
End-to-end summarization — email received to Case Note created in Salesforce
0 hrs
Manual case note creation per week — was 15+ hours of paralegal time
100%
PDF and DOCX attachment coverage — every file extracted, summarized, and stored
Faster matter documentation from first email to complete structured Case Note
0
Silent integration failures — every error captured in Error Log with type, source, and timestamp

Challenge vs. Solution

Six Document Workflow Problems That Consumed the Legal Team Every Week — and Six Fixes That Automated the Entire Process

✕ Before — The Challenges 6 Problems
2–3 hours daily lost to manually reading client emails and opening each attachment one by one across multiple active matters.
Case notes written by hand for every email — no standardisation in format, depth, or which details were captured.
No Matter-linked history in Salesforce — notes lived in inboxes and personal documents, disconnected from the case record.
PDF attachments required separate tools to open and read — adding time to every email that included legal documents.
Inconsistent case documentation created compliance and audit risk — no timestamped trail of what was reviewed and when.
No visibility into integration failures — if an attachment failed to process, the team had no way to know until a gap was discovered manually.
✓ After — What We Built 6 Fixes
We built an EmailMessage trigger in Salesforce Flow that fires on every inbound email — validation, GPT summarization, and Case Note creation run automatically in under 60 seconds.
We configured a structured GPT prompt that extracts key discussion points, important updates, and action items — stripping signatures, footers, and repeated boilerplate.
We built a custom Case Note object that links every email summary and attachment summary directly to the relevant Matter in Salesforce — full history in one place.
We implemented separate DOCX (sync) and PDF (async Textract) processing paths — Textract Job IDs stored in Salesforce to handle Apex governor limits cleanly.
We added built-in compliance checkpoints — every processed email and attachment carries a timestamped record, making audits a lookup rather than a reconstruction.
We created a custom Error Log object capturing AWS upload failures, GPT API errors, and Textract issues — with type, source, and timestamp — so nothing fails silently.

What We Did

Five Phases That Took the Email Workflow From Manual Inbox Triage to Full Automation

Discovery

Mapped Every Workflow Gap Before Writing a Single Line of Code

We audited the full email-to-case-note lifecycle across the legal team — identifying where time was lost, where compliance gaps existed, and which file types required separate handling. We designed the Apex architecture, custom object schema, and GPT prompt structure before any development began.

Process Mapping Gap Analysis Architecture Blueprint Custom Object Schema Design
Core Build

Built the Salesforce EmailMessage Trigger and GPT Summarization Pipeline

We implemented the Salesforce Flow trigger on the EmailMessage object, the Apex callout to OpenAI GPT with a structured legal prompt, and automatic Case Note creation linked to the Matter. We built the feature-activation toggle in Custom Settings so admins can pause AI processing without a deployment.

Salesforce Flow Apex Triggers OpenAI GPT API Custom Settings Case Note Object
Attachment Processing

Wired DOCX and PDF Through Separate Extraction Paths

We built type-detection logic that routes DOCX files through synchronous text extraction and PDF files through AWS Textract via async jobs — storing Textract Job IDs in a custom Salesforce object to retrieve results with a scheduled Apex job, fully within governor limits.

AWS S3 AWS Textract AWS Lambda Scheduled Apex Textract Job Object DOCX Sync Processing
Compliance & Error Handling

Made Every Failure Visible and Every Audit Instant

We built the Error Log object to capture AWS upload failures, GPT API errors, and Textract exceptions — each with error type, source, and timestamp, filterable in standard Salesforce views. We also embedded timestamped compliance checkpoints into every processed email and attachment record.

Error Log Object Audit Trail Apex Exception Handling Salesforce Views
Handover & Enablement

Delivered Full Admin Control With Zero Code Required to Operate

We handed over a system that legal admins can control entirely through Salesforce — enabling or pausing AI processing via a single Custom Metadata flag, monitoring errors through standard filtered views, and reviewing full summarization history on every Matter record without touching configuration or code.

Custom Metadata Admin Enablement Matter Record Views Error Monitoring

Before this, every email was a task. Now the entire workflow runs itself. Our paralegals spend their time on actual legal work, not inbox triage.

— Twopir Project Lead · US Legal Tech Platform · 2024

Key Outcomes

What Changed — In Numbers and in Practice

0 hrs

Manual case note creation eliminated — every week, permanently

The 15+ hours per week legal staff spent writing case notes by hand now runs automatically for every matter-linked email received in Salesforce.

<60s

End-to-end summarization — from inbound email to structured Case Note

The entire pipeline — email validation, GPT summarization, Case Note creation linked to the Matter — completes in under 60 seconds with no human in the loop.

100%

Attachment coverage — every PDF and DOCX extracted and stored automatically

Both document types are handled through dedicated processing paths: DOCX synchronously, PDF via async AWS Textract with job tracking in Salesforce — no file is skipped.

Faster matter documentation from first contact to complete case record

What previously required a paralegal to read, summarize, and file manually now completes in a single automated pass, keeping Matter records current without manual intervention.

Instant

Audit readiness — compliance trail built into every processed email

Every summarized email and attachment carries a timestamped record in Salesforce, eliminating the multi-day manual reconstruction that compliance audits previously required.

Full control

Admins pause or enable AI processing with a single toggle — no deployment needed

The feature-activation flag in Custom Metadata means the legal team's Salesforce admin can manage the entire AI pipeline without touching code or raising a change request.


Technologies Used

The Tools and Techniques Behind This Engagement

Salesforce Service Cloud OpenAI GPT API AWS Textract AWS S3 AWS Lambda Apex Triggers Salesforce Flow Scheduled Apex Custom Metadata Custom Settings EmailMessage Object Case Note Object (Custom) Textract Job Object (Custom) Error Log Object (Custom) Apex REST Callouts DOCX Sync Processing PDF Async Processing

Running a similar legal or professional services operation?

We'll audit your current email and document workflow, identify exactly where automation can eliminate manual effort, and show you what a Salesforce + GPT pipeline would look like for your caseload — findings delivered in 5 business days, no commitment required. We cover US EST, UK GMT, and AEST time zones.

Ready to Replace Manual Effort With AI-Powered Automation?

Twopir has delivered Salesforce automation for 500+ clients across the US, UK, Australia, UAE, and Canada over 12+ years. We build pipelines that run without human intervention — and stand behind them.

12+ Years  ·  500+ Clients  ·  Salesforce Gold Partner  ·  US  ·  UK  ·  Australia  ·  UAE  ·  Canada