Building an AI Assistant for a Legal Team
TL;DR β I built an AI-powered Client Relationship Management (CRM) workflow for a small legal team, integrating Outlook, a self-hosted CRM, and LLMs to automate client opportunity tracking, task creation, and internal coordination.
The project main design principles are:
β
Simplicity: for adoption by non-technical users
β
Data ownership: self-hosted infrastructure on client premises
β
Vendor independence: open API stack with no SaaS lock-in
Code and documentation available:
Github β CRM Workflow
Context and Motivation
The legal office manages hundreds of ongoing client matters, including:
βͺοΈ Intellectual property (IP) filings (logos, patents)
βͺοΈ Company registrations
βͺοΈ Tax reporting and compliance
Each request type follows a multi-step workflow, for example:
initial consultation β contract sent β ... β invoice paid
Keeping track of all these pipelines manually created overhead and risk of human error. Commercial CRMs were too bulky, expensive, or unfit for the officeβs custom legal workflows.
This solution was built to evolve step by step, from Excel to CRM to agentic CRM.
Design Philosophy
π Human-in-the-loop: AI augments but doesnβt replace staff. Humans validate and refine updates.
π§ Built for AI: From day one, the system was architected for AI integrationβwell-documented, API-first, and fully observable.
π§© Hackable CRM: Lightweight, REST-based, with a clean UI and open source deployment.
Features
β
Already Implemented
βͺοΈExtract client and opportunity information from incoming emails
βͺοΈAutomatically generate notes and tasks linked to each case based on internal workflow rules
π In Progress
βͺοΈSummarize case files β for internal collaboration and client updates
βͺοΈCRM AI chatbot β conversational access to CRM records (e.g. βWhatβs the status of Client Aβs trademark?β)
βͺοΈUser Role Management β integrate MS & CRM user permissions for secure multi-user collaboration
Architecture & Stack
π§ LLM Engine
Connects to the CRM, parses emails, makes decisions using tools like read_email()
, create_task()
(e.g. βCreate note for client X about signed contractβ)
π© MS Graph API
Fetches emails, calendars, and SharePoint data
π Twenty CRM API
Writes updates to CRM about clients, opportunities, and creates notes, and tasks
π₯οΈ Self-hosted frontend
Twenty CRM self-hosted app, a lightweight CRM frontend supporting multi-user authentication
AI CRM system architecture
Data flow
The client updates are sourced from the business email inboxes and interpretated by the LLM into actionable updates to the CRM.
AI workflow
From the agent perspective, each email triggers a new request with the following inputs and expected output / actions
Inputs
- Outlook emails
- CRM records
- Legal process metadata
Outputs:
- New or updated CRM opportunities
- Auto-generated tasks and notes
- Audit-friendly logs of every AI action
The agent uses tools and APIs to respond to changes in email context:
- Parse email content
- Check if client exists β update or create
- Match or create opportunity
- Create note or task if required
Visualizing the agent prompt as a workflow diagram
Why This Matters
A CRM designed for AI is a solid foundation for scaling legal operations.
Rather than retrofit AI into an existing system, we built an open, modular CRM from the startβfully ready for future LLM integration.
The AI assistant does not replace humans, it does the repetitive work for them and enable them to focus on the key decisions.