# Communications Agent — Specification

## Purpose

The front-line agent receives every inbound communication — email and LINE — before a human touches it.
It loads the client profile and matter context, classifies the message, and either drafts a response
for attorney approval or routes it to the right person with a summary.

No client communication falls through. No attorney wastes time composing routine responses.
Every approved draft becomes training data — after 6 months the agent sounds like the firm.
After a year it is the firm's voice.

---

## Architecture

```
Inbound message (email or LINE)
        ↓
Parser — extracts sender, subject, body, attachments
        ↓
Identity resolution — sender email/LINE ID → client record
  ├── Known client → load client KB + active matters
  ├── Known contact (opposing counsel, court) → load contact record
  └── Unknown sender → create lead record, draft acknowledgement
        ↓
Classification engine
        ↓
Action — draft / route / escalate / intake
        ↓
Staff queue → attorney approval → send
        ↓
Approved response → training data
```

---

## Classification Logic

### Class 1 — Routine (agent drafts, attorney approves, 1-click send)
- Status queries: "What is happening with my case?"
- Hearing date queries: "When is the next court date?"
- Document confirmation: "Did you receive what I sent?"
- Appointment requests and confirmations
- Payment receipts and retainer balance queries

**Agent action:** Draft response based on current matter status from system. Queue for attorney review.
**SLA:** Draft ready within 2 minutes of receipt. Attorney reviews at next available moment.

### Class 2 — Document received (intake workflow)
- Any message with an attachment
- Known document types: court filings, financial disclosures, contracts, title documents (chanote),
  DBD extracts, opposing party correspondence forwarded by client

**Agent action:**
1. Classify document type
2. Link to correct matter
3. Store in document system
4. Notify assigned staff (attorney or paralegal depending on document type)
5. Draft acknowledgement to sender: "We have received your document and will review shortly."

### Class 3 — Attorney attention required (summarised + escalated immediately)
- Any communication from opposing counsel (flag on sender record)
- Any communication from court (flag on sender domain/contact type)
- Settlement offers or demands (keyword detection)
- Anything containing legal deadlines or response requirements
- Emotionally escalated family matter clients (tone detection)
- Anything the agent classifies as uncertain

**Agent action:** Do not draft a response. Summarise the message in 3–5 sentences. Push to attorney queue with URGENT flag. Notify via LINE if urgent threshold met.

### Class 4 — New enquiry (unknown sender)
- Sender not in system

**Agent action:**
1. Create lead record
2. Draft acknowledgement: "Thank you for contacting GPS Legal. We will be in touch shortly."
3. Queue for conflict check before matter can be opened
4. Flag for attorney — new potential client

### Class 5 — Internal routing only (no client response)
- Billing dispute → admin queue
- Document processing question → paralegal queue
- Anything addressed to a specific staff member → that person's queue

---

## Staff Routing Table

| Message type | Primary recipient | Notify also |
|---|---|---|
| Court correspondence | Lead attorney | — |
| Opposing counsel | Lead attorney | — |
| Settlement / demand | Lead attorney | — |
| Status query (routine) | Paralegal (with draft) | — |
| Document received | Paralegal (to process) | Attorney (notification) |
| Billing query | Admin | — |
| Urgent / emotional | Lead attorney | — |
| New enquiry | Attorney | — |

Routing is based on matter assignment — each matter has a lead attorney and assigned paralegal.
Messages about a specific matter route to those people, not globally.

---

## LINE Integration

LINE is a first-class channel, not an afterthought. Thai clients communicate via LINE
as much as or more than email. The same classification and routing logic applies.

**LINE → System:**
- LINE Messaging API webhook receives messages
- Same parser, same classification, same routing
- Images/files sent via LINE are treated as document intake

**System → LINE:**
- Attorney-approved responses can be sent back via LINE
- Deadline reminders and hearing notifications sent proactively to client's LINE
- Urgent escalations notify the attorney via LINE

**LINE group handling:**
If the firm uses LINE groups for internal coordination — messages in those groups are
not processed by the agent. Only client-facing LINE connections.

---

## The Training Loop

Every message the agent drafts that an attorney approves (with or without edits) becomes training data.

```
Agent drafts response
        ↓
Attorney reviews
  ├── Approves as-is → positive training example
  ├── Edits then approves → training example with correction signal
  └── Rejects / rewrites → negative example (agent learns what not to do)
        ↓
Weekly fine-tune on Workbeast incorporates new examples
        ↓
Draft quality improves continuously
```

**Timeline:**
- Month 1–2: Agent drafts are rough — attorney edits frequently. That's the training.
- Month 3–4: Draft quality improving. Routine responses need minimal edits.
- Month 6: Routine correspondence largely approved as-is. Attorney focuses on complex and sensitive.
- Month 12: Agent voice matches the firm's. Drafts sound like they were written in-house.

---

## Shared Inbox vs. Individual Addresses

**Open question — to resolve in design session:**

If the firm uses individual attorney email addresses (attorney@gpslegal.com):
- Each attorney's inbox is monitored separately
- Routing is by recipient, not just by matter assignment
- LINE accounts also likely individual

If the firm uses a shared inbox (info@gpslegal.com or legal@gpslegal.com):
- Single point of ingestion — simpler architecture
- All messages go through the same agent
- Routing entirely by matter assignment and message classification

**Recommendation:** Move to a shared inbox (if not already) for the primary client-facing address.
Individual addresses can remain for direct correspondence. The agent monitors the shared inbox.
This is the most common architecture for firms of this size using an AI triage layer.

---

## Open Questions for Design Session

- [ ] Current email setup — shared inbox or individual addresses?
- [ ] Does she currently respond to LINE messages from a personal LINE account or a business account?
- [ ] Who currently handles incoming messages when she is in court?
- [ ] What is the expected response time clients currently receive vs. what they expect?
- [ ] Are there clients or matter types where AI drafting is NOT appropriate — where every response must come personally from the attorney?
- [ ] What keywords or sender patterns should always trigger immediate escalation regardless of content?
