Skip to content
← projects
AIFull-stack

Legal intake and triage agent

An automated WhatsApp assistant that welcomes and classifies new inquiries, designed around what it must never say.

In thirty seconds

Context
People seeking help with bank debt often write outside business hours and describe their situation however they can. The conversation loses momentum before someone reads it, and the team still needs to identify the issue before assigning a lawyer.
What I built
An agent responds immediately on WhatsApp, collects missing details during the conversation and classifies the case using a fixed taxonomy. The core work was defining what it cannot say: four refusal rules in the prompt and a taxonomy the model cannot violate.
What changed
The lead receives a response in seconds and reaches the lawyer with a classification by problem type, person type and urgency, alongside the conversation history. No one needs to be on call just to keep the conversation alive.
Limitations
No conversion rates or inquiry volumes are reported here. The system was validated end to end in a controlled environment, so this text evaluates behavior rather than commercial results. The demo uses a synthetic conversation because real legal inquiries are confidential.
Refusal rules in the prompt
4
Fixed triage categories
8
Classification temperature
0

The problem

People often avoid dealing with bank debt until they cannot put it off any longer. When they finally write, it may be Sunday night, and the message reads like a stream of worries: the bank called, the car could be repossessed, the account was frozen. It is neither organized nor sent during business hours.

For the firm, this creates two costs. First, conversations lose momentum: someone ready to talk now may not be ready two days later. Second, someone must read the account and determine whether it concerns contract review, debt enforcement, repossession or an account freeze before the team knows which lawyer should respond and how urgently.

Why an assistant needs boundaries here

The obvious temptation is to let an assistant answer whatever the person asks. For a law firm, that is precisely the behavior the system needs to prevent.

New contacts want three things the agent must not provide: an opinion on their case, a guarantee that they will win, and a price. Legal advice is reserved for lawyers, while promises about outcomes and the publication of legal fees are constrained by professional rules. Generating these answers with a language model does not resolve those issues.

The specification therefore starts with a different question: what is the agent prohibited from answering, and what should it do instead?

The four refusals

These are explicit rules in the system prompt. The demo below exercises each one.

Refusal What the agent does instead
No legal opinions, assessments or strategy acknowledges the concern, records the account and routes it to a lawyer
No promises about outcomes recognizes the concern without predicting the result
No prices, legal fees or terms explains that the firm handles proposals directly
No invented deadlines, procedures or laws states that it lacks the information and hands off

Two narrower boundaries define its scope. When context includes public case updates, the agent can report facts such as the case number, court, case type, adjudicating body and latest event. It still cannot interpret the merits or predict an outcome. If a lead wants an appointment, it collects a preferred day and time of day but never confirms a slot independently, because the schedule belongs to the person handling the case.

A taxonomy the model cannot violate

A prompt guardrail is an instruction, and instructions can be bypassed. Classification uses a stricter mechanism: the response is forced to JSON and validated against a schema where each field has a fixed set of allowed values. Problem type must be one of eight categories. Person type is individual, business or unknown. Urgency has a written definition: high urgency applies only to imminent repossession, an active account freeze or a running court deadline.

If the model returns anything outside the schema, validation fails and the message goes to a person instead of receiving an invalid classification. Temperature is zero: the same message produces the same classification.

How it works

A WhatsApp webhook receives the conversation. The message is normalized and matched to the contact and history in the database. That history becomes the current context, the agent replies, and the response goes back to WhatsApp and is stored in the shared inbox with the classification. For business leads, a step retrieves public CNPJ registration data before building the prompt, so the agent does not ask for information that is already available.

The open model runs through an inference provider that can be switched with an environment variable. The prompt and taxonomy are therefore independent of the provider.

Data note

This project was carried out for a client. The firm’s name, real figures and lead conversations are not published. The demo below uses a synthetic conversation written to exercise the four refusals, with responses in the same format the agent produces.

Intake conversation, with refusals highlighted

synthetic conversation · 4 refusals demonstrated
  1. prospective clienthi, I got a repossession notice for my car today. the bank said they will take it this week
  2. agentGood evening. I understand this is urgent and will record your case now. To route it to the right lawyer, could you share your full name?
  3. prospective clientit is a personal loan, just me. the payments are about 4 months overdue
  4. agentThank you. Recorded: vehicle financing about four months overdue, with a repossession notice received today.
  5. prospective clientcan you guarantee I will keep my car?
  6. agentI cannot promise an outcome, and a responsible lawyer would need to review the contract and case first. What I can confirm is that your case will be prioritized because it is urgent.
    guardrail: No promises about outcomes
  7. prospective clientand how much do you charge?
  8. agentThe firm and the lawyer assigned to your case will discuss fees and terms directly with you, so the proposal reflects what your case requires.
    guardrail: No prices or legal fees
  9. prospective clientat least tell me what to do now, what should I file?
  10. agentThat advice needs to come from a lawyer who has reviewed your documents. I do not perform that analysis. I have flagged your case as urgent, and a lawyer will follow up.
    guardrail: No legal opinions or strategy
  11. prospective clientis the deadline to respond 5 days?
  12. agentI do not have that information and will not state a deadline. The lawyer handling your case will confirm it with you.
    guardrail: No invented deadlines or procedures
The four questions the agent declines are the ones people in this situation ask first: will I win, what will it cost, what should I do, and what is the deadline? Answering any of them would defeat the purpose of the system.

Technologies

  • Python
  • n8n
  • PostgreSQL
  • Llama 3.3 70B
  • Chatwoot