"recipient_name": "Tomasz Wisniewski",
"recipient_address": {
"text": "Tomasz Wisniewski\\n1200 Commerce St #2045\\nTacoma, WA 98402"
},
"sender": "A. Wisniewska\\n19 Birch Hollow Rd\\nBend, OR 97701"
}
Redfern is a fictional company. It was made up to show how Filestack works in mail and document services, so the firm, its people and its figures are invented.
What powers it is real. Every upload, Envelope OCR read, document detection and OCR pass in Redfern is a real call to the Filestack API.
View source on GitHubWhat Is Digital Mailroom Automation?
Digital mailroom automation turns incoming post into routed, searchable digital mail. Each envelope is scanned, its sender and recipient are read, and the item goes to the named person, with the contents indexed for search. Filestack’s envelope_ocr task returns the sender, recipient name and recipient address as named fields, so routing becomes a directory lookup.
Read by staff
- Scan Each envelope photographed
- Staff read it Name and box number typed in
- Mailbox Filed by hand
Read by Filestack
- Upload The scan lands in Filestack
- envelope_ocr Sender and recipient as fields
- Directory match Routed to the named person
- Tasks
-
envelope_ocr,doc_detectionandocr - Input
- Scans and phone photos of envelopes and letters
- Envelope fields
sender,recipient_nameandrecipient_address- Contents
- Straightened by
doc_detection, read byocrfor full-text search - Access
- Each read carries a policy signed with your app secret
- Trigger
- The
fp.uploadwebhook, or a Workflow on every upload - Plans
- Envelope OCR, OCR and document detection on paid plans. Pricing
- Demo source
- Redfern, a Next.js app. View on GitHub
One Signed URL Reads the Envelope
To read an envelope with Filestack, put envelope_ocr in a signed CDN URL in front of the scan’s handle. The response names each part of the address block, so your code works with fields instead of positions on the page.
cdn.filestackcontent.comThe Filestack CDNsecurity=p:POLICY,s:SIGNATUREA policy your server signs, scoped to one handleenvelope_ocrReads the envelopeJg9vWLjTB6ky5UPUHGKRThe scan's handle, a sample
recipient_name- Matched against the staff directory to choose a mailbox.
recipient_address.text- The full recipient block, with the box or suite number that confirms the match.
sender- Stored with the item, so post is searchable by who sent it.
- Empty fields
- A scan that is not an envelope returns every field empty, and the item goes to review.
"recipient_address": {
"text": "Tomasz Wisniewski\\n1200 Commerce St #2045\\nTacoma, WA 98402"
},
"recipient_name": "Tomasz Wisniewski",
"sender": "A. Wisniewska\\n19 Birch Hollow Rd\\nBend, OR 97701"
}
Inside Redfern, a Mailroom Built on Filestack
Redfern is a demo virtual mailroom built on Filestack and Next.js. The firm is invented and every file call is real: scans upload from the browser, a server route signs each read, envelope_ocr routes the item, and the contents are indexed.
File Picker uploads a batch of envelope scans from the browser straight to Filestack storage. Each file comes back with a handle, the one value the app stores.
envelope_ocr,ocranddoc_detectionrun on signed requests. A server route signs a policy for one handle withreadandconvert, valid for ten minutes, and signs only the tasks on its allowlist.The app matches
recipient_nameagainst the staff directory, on the full name first and then the surname. A match files the item to that person's inbox, and every other item waits in a supervisor's queue.The letter inside takes a two-task chain in one URL.
doc_detectionfinds the page in the photo and flattens it, thenocrreads the flattened page, and itstextfield feeds the search index.
client.picker({
accept: ['image/*'],
maxFiles: 50,
onUploadDone: ({ filesUploaded }) => {
filesUploaded.forEach((file) => readEnvelope(file.handle));
},
}).open();
export function signedUrl(handle, tasks) {
const expiry = Math.floor(Date.now() / 1000) + 600;
const policy = Buffer.from(JSON.stringify({ call: ['read', 'convert'], handle, expiry }))
.toString('base64').replace(/\\+/g, '-').replace(/\\//g, '_');
const signature = createHmac('sha256', process.env.FILESTACK_APP_SECRET)
.update(policy).digest('hex');
return `https:/
}
const { sender, recipient_name } = await res.json();
const person =
DIRECTORY.find((p) => recipient_name?.includes(p.name)) ??
DIRECTORY.find((p) => recipient_name?.includes(p.surname));
await saveItem(handle, person
? { to: person.id, sender }
: { queue: 'review', sender });
'doc_detection=coords:false,preprocess:true',
'ocr',
]));
const { text } = await res.json();
await searchIndex.add({ handle, text });
What a Digital Mailroom Needs to Route Post
A digital mailroom needs scan intake, storage, an address reader, deskewing for photographed letters, full-text indexing and a review queue. Filestack hosts the files and returns the address block as fields, and your app keeps the directory and the queue.
Build It In-House
Read It With Filestack
Your app keeps the directory match and the review queue.
Tour the Redfern Mailroom
Upload envelope scans on the Redfern demo page, then sign in as staff to see each item routed to a desk or held for a supervisor.
Run the Mailroom on Upload Webhooks
To read envelopes as they arrive, subscribe a server endpoint to the File upload webhook and read each new scan once. Verify FS-Signature on every delivery and key each record by handle. Webhooks
-
Read on fp.upload
The File upload event names each new file. Its handle is the last segment of
text.url. -
Verify every delivery
Recompute HMAC-SHA256 over
FS-Timestamp, a period and the raw body, with the endpoint's secret. -
Store the fields once
Save the
envelope_ocrfields against the handle. Each request runs the task again. -
Key records by handle
Filestack retries a delivery your server answers with an error, so a handle already on record gets a 204.
-
Keep the review queue in view
Unmatched names and empty reads go to a supervisor with the reason attached.
-
Read contents in a Workflow
A Workflow runs
doc_detectionandocron the server for a whole batch.
export function verifyWebhook(raw, timestamp, signature) {
if (!timestamp || !signature) return false;
const expected = createHmac('sha256', process.env.FILESTACK_WEBHOOK_SECRET)
.update(`${timestamp}.${raw}`)
.digest('hex');
const a = Buffer.from(expected);
const b = Buffer.from(signature);
return a.length === b.length && timingSafeEqual(a, b);
}
"action": "fp.upload",
"text": {
"url": "https:/
"type": "image/png",
"filename": "scan.png"
}
}
Ways to Read the Recipient Off an Envelope
Envelope OCR returns the recipient block as fields. General OCR returns every line of text with its position on the page, and staff read the scan by eye.
| Staff read and type | General OCR | Filestack envelope_ocr |
|
|---|---|---|---|
| What comes back | A name and box number typed into your system | Every line of text with its coordinates | sender, recipient_name and recipient_address |
| Finding the recipient | Judgment on each envelope | Rules that choose a block by where it sits | The task labels the recipient block |
| A name printed apart from the address | Read by eye | Found by position rules | Plain ocr on the same
scan reads the name |
| Growth in volume | Staff hours grow with the post | Engine hosting grows with the post | Plans by usage. Pricing |
| Time to production | Hiring and training | An OCR engine, a parser and hosting | Most teams ship their first upload within minutes |
Staff reading suits a mailroom with a few dozen items a day and envelopes that need judgment.
Earth Class Mail Case Study
Earth Class Mail turns paper mail into searchable digital documents. Filestack OCR, then called Filestack Capture, read and sorted the mail automatically.
"A simple integration with Filestack's content intelligence API allowed us to offload the analysis of a large volume of mail quickly and reliably. This automation has proven critically important as our team has more time to focus on enhancing our core product."
- 70%of Earth Class Mail's mail processing completed through the Filestack API
- 50%+increase in the overall auto-delivery rate
- 6,000+customer inboxes served
- 10,000images processed in a day, at peak
Envelope OCR Beyond the Mailroom
The scan, read and route pattern also runs returned-mail handling, remittance capture, parcel sorting and searchable archives.
Returned mail and address correction
Read the recipient block on each returned item and update the record.
envelope_ocr
Check and remittance capture
Flatten the photographed slip, then read its text.
doc_detectionocr
Parcel label sorting
Read the label text off each parcel photo and route the parcel.
ocr
Searchable archives
Index a year of post by sender, recipient and the words inside.
ocr
Screening emailed documents
Scan files that arrive by email or upload before staff open them.
virus_detection
Batch intake
Run the contents chain on every upload in a morning's batch.
Workflows
Route every scanned envelope to the right desk.
- 70% of Earth Class Mail's mail processing completed through the Filestack API
- Most teams ship their first upload within minutes
- SOC 2 compliant
Digital Mailroom Automation FAQs
What is a digital mailroom, and how is it automated?
A digital mailroom receives paper post, scans it and delivers each item to its recipient as a digital file. An automated mailroom reads the envelope, routes the item to the named person and indexes the contents for search.
How does envelope OCR differ from regular OCR?
Envelope OCR returns the sender, recipient name and recipient address as named fields. Regular OCR returns all the text on the page with word positions, and your code decides which block is the recipient.
Where does an unmatched envelope go?
An unmatched envelope goes to a review queue. The app tries the full recipient name, then the surname, and a scan that returns empty fields also lands in review with the reason.
Which plans include Envelope OCR?
Envelope OCR runs on paid plans, with a free trial. Each read carries a policy signed with your app secret that grants read and convert on the scan’s handle. See pricing.
Can the contents be read on the server as each scan arrives?
Yes. A Filestack Workflow attached to the upload runs doc_detection and ocr as each scan arrives, and the fs.workflow webhook delivers the results to your endpoint.
Is Redfern a real company or a Filestack customer?
Redfern is a fictional company, created to show how Filestack works in mail and document services. The firm, its people and its figures are invented, and the demo runs on the real Filestack API.
Can I see the code behind the Redfern demo?
Yes. Redfern is open source on GitHub in the filestack-use-cases repository, under apps/fs-mailroom. It is a Next.js app with the signing route and the routing code.