Kancelaria DMS — Apps Script Document Management for Polish Law Firms
A complete Document Management System for law firms, built on Google Workspace (Sheets + Apps Script + Drive + Gmail Add-on). Manages cases, clients, deadlines, correspondence, leads (CRM), and Polish Post tracking.
Built and used in production by a Polish attorney (radca prawny) for his own practice (ktzr.pl).
Features
- Case management — cases, parties, courts, signatures, attorneys
- Task & deadline tracking — calendar integration, email reminders
- Email integration — Gmail Add-on, automatic email-to-case matching with Gemini AI
- Document AI — automatic summarization of Drive documents (Gemini)
- CRM — leads, contacts, follow-ups
- Polish Post tracking — shipment book with status updates
- Dashboard — modern responsive UI in sidebar / web app
Tech Stack
- Google Apps Script (V8 runtime)
- Google Sheets (as database)
- Google Drive (file storage)
- Gmail API + CardService (add-on)
- Gemini API (document summarization, email matching)
- Bootstrap 5 + Chart.js (UI)
Setup
- Create a new Google Sheet — this will be your DMS database.
- Extensions → Apps Script — paste contents of
Code.gs,Index.html, andappsscript.json(you'll need to enable manifest editing in Project Settings). - Project Settings → Script Properties — add the following keys.
The code reads these automatically — no further edits needed.
GEMINI_API_KEY— get one from https://aistudio.google.com/apikeyCRM_DRIVE_PARENT_ID— Drive folder ID where lead folders will be createdDMS_DRIVE_PARENT_ID— Drive folder ID where case folders will be createdFIRM_DOMAIN— Your firm's email domain (e.g.yourfirm.com). Used for incoming/outgoing email classification. If left unset, all emails will be classified as "incoming".
- (Optional) External users access — If non-domain Google accounts need
access to the web app, edit the
ALLOWED_EXTERNALarray near the top ofCode.gswith their emails. Leave empty for domain-only access. - Deploy → New deployment → Web app (Execute as: User accessing the web app).
- First run will create all required sheets automatically.
- Populate the
Prawnicy_DMSsheet with your team's names and emails (thePRAWNICYarray in code is just a fallback when the sheet is empty). - To use as a Gmail Add-on: Deploy → Test deployments → Install —
the add-on icon appears in Gmail's right sidebar.
Required OAuth Scopes
This app requests broad scopes — review them in appsscript.json before
deploying. The most extensive ones:
mail.google.com/— full Gmail access (labeling correspondence, threading emails to cases, reading attachments)drive— full Drive (creating case folders, uploading documents)spreadsheets— full Sheets (the DMS database)calendar— full Calendar (deadline reminders)
If your firm requires least-privilege OAuth, you'll need to scope these down and disable the corresponding features.
Project Structure
.
├── Code.gs # All server-side Apps Script logic (~1050 lines)
├── Index.html # Single-page UI (Bootstrap 5 + vanilla JS, ~1550 lines)
├── appsscript.json # Manifest — scopes, add-on config
├── README.md # This file
├── LICENSE # Apache 2.0
├── SECURITY.md # Security policy
└── .gitignore
⚠️ Disclaimer
This is a personal project shared as-is, with no warranty. It was built for my own law practice and reflects Polish legal practice conventions (case numbering, court names, post tracking integration with Poczta Polska, etc.).
Before using in production:
- Run your own security audit
- Ensure GDPR compliance for your jurisdiction
- Verify alignment with your professional secrecy obligations
- This is NOT a certified legal software product
- All client data stays in YOUR Google Workspace — nothing leaves it except document content sent to Gemini API for summarization (consider whether this aligns with your data processing obligations)
Roadmap
This codebase is feature-complete for my own use. Future development focuses on automation tooling around it.
Author
Adam Piotrowski — radca prawny, ktzr.pl
Contact: [email protected]
License
Apache License 2.0 — see LICENSE.