AI Assistant for Legal Team
Legal CRM workflows administered by AI
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: 1. Parse email content 2. Check if client exists → update or create 3. Match or create opportunity 4. 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.