> ## Documentation Index
> Fetch the complete documentation index at: https://docs.parsalink.io/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Agents

> The CRM AI assistant is built from 16 specialized per-domain agents — one for contacts, one for opportunities, one for email, and so on — coordinated by a router.

<div
  style={{
background: "linear-gradient(135deg, #143D4E 0%, #1C758A 55%, #30C8CA 100%)",
borderRadius: "24px",
padding: "28px",
marginBottom: "28px",
color: "#FFFFFF",
boxShadow: "0 20px 50px rgba(20, 61, 78, 0.22)",
position: "relative",
overflow: "hidden",
border: "1px solid rgba(255,255,255,0.08)"
}}
>
  <div
    style={{
position: "absolute",
top: "-36px",
right: "-36px",
width: "170px",
height: "170px",
background: "rgba(255,255,255,0.08)",
borderRadius: "999px"
}}
  />

  <div
    style={{
position: "absolute",
bottom: "-48px",
left: "-24px",
width: "130px",
height: "130px",
background: "rgba(255,255,255,0.06)",
borderRadius: "999px"
}}
  />

  <div
    style={{
  display: "inline-flex",
  alignItems: "center",
  background: "rgba(255,255,255,0.14)",
  color: "#FFFFFF",
  padding: "7px 14px",
  borderRadius: "999px",
  fontSize: "12px",
  fontWeight: "700",
  marginBottom: "12px",
  letterSpacing: "0.08em",
  textTransform: "uppercase"
}}
  >
    PER-DOMAIN AGENTS
  </div>

  <p style={{ margin: 0, fontSize: "16px", lineHeight: "1.9", maxWidth: "760px", color: "#FFFFFF" }}>
    Instead of one giant assistant that knows everything, ParsaLink runs a fleet of small, focused agents. Each one owns a single CRM domain — and the right one is picked for you based on what you ask.
  </p>
</div>

## Why Multiple Agents?

A single all-knowing assistant has to load every tool, every example, and every instruction every time it answers — even when you're just asking it to mark a task complete. That's expensive (lots of LLM tokens), slow, and less accurate.

ParsaLink routes each request through a small **classifier** first, identifies the right domain (contacts, opportunities, email, etc.), and then loads only that domain's tools and system prompt. You get faster, cheaper, more accurate responses.

The agents share a common base prompt (formatting rules, response style, when to confirm vs. act) but each one has domain-specific knowledge layered on top.

***

## The 16 Domains

| Agent              | What it owns                                                                         |
| ------------------ | ------------------------------------------------------------------------------------ |
| **contacts**       | Search, create, update, bulk import, merge, duplicate checks for Contact records     |
| **accounts**       | Same shape, for Account (company) records                                            |
| **opportunities**  | Deal CRUD, stage moves, probability + amount updates, related contact/account lookup |
| **cases**          | Support case CRUD, priority + status transitions                                     |
| **tasks**          | Task CRUD + reminders, due-date logic, automation-spawned tasks                      |
| **email**          | Drafting, sending, template creation/cloning, email-account routing                  |
| **automations**    | Building new automation rules from a natural-language description                    |
| **meeting-notes**  | Reading and writing meeting note attached to calendar events                         |
| **tags**           | Tag CRUD across all entity types, segmentation queries                               |
| **comments**       | Threaded comments on contacts, accounts, opportunities, cases, tasks                 |
| **analytics**      | Running ad-hoc analytics queries (generates safe Django ORM Python under the hood)   |
| **pipelines**      | Pipeline + stage CRUD, opportunity pipeline configuration                            |
| **communications** | Twilio call logs + SMS context lookup                                                |
| **calendar**       | Booking events, comparing team availability, sending invites                         |
| **web**            | Web search for facts outside the CRM                                                 |
| **shared-base**    | Common ground rules every other agent inherits                                       |

The classifier may activate **multiple** namespaces for one message. Asking *"Show me all the qualified contacts at Globex with an open opportunity, and draft them an intro email"* loads `contacts`, `accounts`, `opportunities`, and `email` together.

***

## How the Router Decides

The router classifier (`router-classifier` prompt template) takes your raw message and returns a JSON object like:

```json theme={null}
{
  "intent": "send_intro_email",
  "namespaces": ["contacts", "email"],
  "confidence": 0.96,
  "reason": "User wants to email new contacts in a segment"
}
```

The picked namespaces' tools and system prompts are then loaded for the actual answer.

<Note>
  You'll usually see this happen invisibly. In some borderline cases the agent may ask a quick clarifying question if the classifier is unsure (e.g. *"Did you mean to update the contact or the opportunity?"*).
</Note>

***

## Customizing the Agents (Admin)

All 16 prompts live in **Admin → LLM → Prompt Templates** with `template_type = ai_agent`. They're versioned and audit-logged, so tuning the wording of a domain agent doesn't require a code deploy.

Pick a template, edit the body, save. The change applies on the next message — no restart needed.

<Warning>
  Editing the **agent-shared-base** template affects every domain agent. Test changes on a non-production workspace first if you're making big structural edits.
</Warning>

***

## Adding Capabilities

Each agent gets its set of tools from the matching directory under `packages/django/crm/ai_tools/` — `contacts.py`, `accounts.py`, etc. Adding a new capability to an agent is a code change (new function decorated with the tool registration). New tools are surfaced to the LLM automatically once the agent's namespace is loaded.

If you have an idea for a capability that doesn't fit a domain — open a request and we'll figure out where it belongs.

***

## Reading the LLM Requests

Every agent call lands in **Admin → LLM → Requests** with: which template was used, which model, the input message, the response, token counts, cost. Useful for:

* Debugging when an agent answers wrong ("it should have used `update_task` but used `create_task`")
* Spot-checking which namespaces were loaded for a borderline message
* Measuring spend per domain (e.g. "the email agent is our biggest spender, time to tighten its prompt")

***

## What Each Agent Can Actually Do

The table above is the elevator pitch. Below is what each agent can concretely accomplish when you ask it something — useful for picking which messages to send into chat (vs. doing it manually).

### contacts

* *"Find John from Acme"* — search by partial name + company; disambiguation prompts when multiple match
* *"Show me everyone tagged VIP who hasn't been emailed in 30 days"* — combined filter on tags + last activity
* *"Create a contact for Sarah Smith, VP Marketing at Stitch, [sarah@stitch.io](mailto:sarah@stitch.io)"* — single-line create
* *"Merge the two Globex Sarahs and keep the most recent email"* — duplicate cleanup
* *"Bulk-update everyone in the prospect stage to source=Cold Outreach"* — mass field updates

### accounts

* *"Find all accounts in the SaaS industry with >100 employees"* — combined firmographic filter
* *"What's the latest activity on the Globex account?"* — timeline summary across linked contacts and opportunities
* *"Show me accounts with no opportunity in the last 90 days"* — stale account triage

### opportunities

* *"Show me deals closing this quarter"* — closing-window filter
* *"Move the Globex deal to Negotiation and set probability to 70%"* — stage + probability update
* *"What's the total amount of open opportunities by stage?"* — pipeline summary

### cases

* *"Show me urgent cases that are still open"* — priority + status filter
* *"Escalate this case to Andrew and tag it `vip-customer`"* — assign + tag in one step

### tasks

* *"What's overdue for me?"* — personal overdue triage
* *"Push everything on Amy's plate due Friday to next Monday"* — bulk reassign + reschedule
* *"Create a task to follow up with the Globex contacts in 3 days"* — relative-date scheduling

### email

* *"Draft an intro email to Sarah at Stitch about our marketing audit"* — AI compose grounded in workspace knowledge
* *"Send the proposal email template to John Smith with the variable {amount} = \$12,500"* — template variable injection
* *"Clone the Proposal Follow-Up template, rewrite it for cold outreach, save as v2"* — template authoring without leaving chat
* *"Show me which template has the best open rate this month"* — per-template analytics

### automations (build via the `automation-builder` template)

* *"Build a rule that sends a welcome email when a contact's source is set to Website, then creates a follow-up task in 3 days"* — describe the workflow in plain English, the agent assembles the trigger + steps and saves the rule
* *"Show me which automation rule sent the most emails last week"* — analytics on rule firing

### calendar

* *"Find a 45-minute slot for Andrew, Amy, and the Globex contacts next week, afternoons"* — multi-user availability intersection
* *"Reschedule today's 3pm to tomorrow at 11am, keep the same attendees"* — single-line reschedule
* *"Book a Teams meeting with John Smith tomorrow at 10am and send him the invite"* — provider-agnostic booking (Google Meet or Teams)

### meeting-notes

* *"Save these notes on the Globex meeting and create a task to send the case study"* — paste raw notes, agent links them to the right event + extracts action items
* *"Summarize what we discussed with Stitch last week"* — surfaces meeting notes filtered by account

### tags

* *"Show me everyone tagged `enterprise` AND `interested`"* — combined tag filter
* *"Create a `renewal-2027` tag and apply it to every customer with a contract expiring in 2027"* — bulk apply
* *"What tags are most common on lost opportunities?"* — segmentation analytics

### comments

* *"Add a comment to the Globex opportunity: 'They want the SOW by Friday'"* — quick note logging
* *"Show me everything I've commented on this week"* — personal activity recap

### analytics

* *"What's our average sales cycle by source?"* — see the [AI Analytics page](/ai/analytics) for the full set
* *"Plot pipeline value by stage for the last 6 months"* — time series with chart

### pipelines

* *"What stages are in the Enterprise opportunity pipeline?"* — pipeline + stage inspection
* *"Add a new stage 'Security Review' between Negotiation and Closed Won"* — pipeline edit

### communications (Twilio)

* *"Show me the call log with John Smith"* — call history retrieval
* *"Send John an SMS: 'Heads up, sending the proposal in 5 minutes'"* — outbound SMS

### web (search-the-internet agent)

* *"What's Globex's latest funding round?"* — public web search for facts outside the CRM
* *"Find the LinkedIn profile of John Smith VP Sales at Stitch"* — researcher-style lookup that doesn't touch the CRM

***

## The Automation Builder

A specific call-out because it's a power user move: the `automations` agent uses the `automation-builder` prompt template to translate natural language into a saved automation rule.

Example:

> *"When a contact's source changes to anything containing 'web', round-robin-assign them to the sales team, tag them `web-lead`, and send them a welcome email after 1 hour."*

The agent:

1. Parses the trigger event (`contact_source_changed`)
2. Parses the trigger conditions (`source contains 'web'`)
3. Parses the sequence of actions (`round_robin_assign`, `add_tag`, `send_email` with a 1-hour delay)
4. Drafts the rule and shows it to you for review
5. Saves and activates on your confirmation

You can iterate from there — the agent can edit the draft if you say "actually delay the email by 2 hours instead of 1" or "add another step that creates a follow-up task after 3 days."

<Tip>
  The automation builder won't activate a rule on the first try without your confirmation. You always get to eyeball the trigger + steps before they go live.
</Tip>
