# CRM Agents



Add a **CRM Agent** step to a [workflow](https://www.withsurface.com/docs/platform/forms/workflows) (it sits
under **AI Agents**). Setup has three steps:

<Steps>
  <Step title="Connect the CRM">
    Pick HubSpot, Salesforce or Attio. The agent uses that connection to find,
    create, update and associate records, so connect it with access that matches
    what you want it to touch.
  </Step>

  <Step title="Define the instructions">
    Write, in plain language, what the agent should do each time it runs: when
    to create a record and when to update an existing one, how to spot
    duplicates (for example, by work email, then company domain), which fields
    to write, and who should own the record. Start from a template if one fits.
    Anything the instructions leave out, the model decides.
  </Step>

  <Step title="Test and visualise">
    Run it against a sample lead and read what it would do before it runs for
    real.
  </Step>
</Steps>

## What the Test Shows [#what-the-test-shows]

The sample lead is generated by AI, and you can edit any field before you run
it. During the test, reads go to your live CRM, while creates and updates are
logged and not sent. Each action is marked as one of these:

| Kind       | Means                                                                                                                                              |
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Read**   | A live lookup, such as finding a contact or the owners. Round-robin and form-routing owner picks are previewed here without moving the rotation on |
| **Create** | A record the agent would create                                                                                                                    |
| **Update** | A record the agent would change                                                                                                                    |

The run ends with **Preview complete** and a count of live reads and logged
changes. Nothing is written to the CRM.

Read the Update rows first. They are the only ones that can write over
something a person entered by hand.

## Deciding What to Allow [#deciding-what-to-allow]

**Start with the blanks.** Filling empty fields and correcting non-empty ones
are different levels of risk. Let it create records and fill gaps before you
let it change existing values.

**Scope the objects.** Contacts and companies are lower stakes than deals. A
deal field is a field your forecast runs on.

**Name the fields.** An agent told to keep everything current churns fields
nobody reads.

**Re-test after every change.** A bad instruction running across the whole
database is expensive to undo.

<Warning>
  Widen the instructions one object at a time and watch the results for a week.
  A CRM agent with a loose instruction on lifecycle stage can re-stage thousands
  of records quietly, and undoing it is a data project.
</Warning>

## What It Works With [#what-it-works-with]

The agent is given the lead's attributes, the form answers, URL parameters and
where the lead came from. On HubSpot it also gets the
[lead score](https://www.withsurface.com/docs/platform/lead-agents/scoring) and its reasoning, which it can
write to a property or use as a threshold if your instructions say so.

| CRM            | What it can write                                                                                              |
| -------------- | -------------------------------------------------------------------------------------------------------------- |
| **HubSpot**    | Contacts, companies, deals, owners, notes and lifecycle stage. It can also enrol a contact in a sales sequence |
| **Salesforce** | Contacts, accounts, opportunities, tasks, owners and custom objects. There is no Lead object                   |
| **Attio**      | People, companies, deals, notes, tasks and owners                                                              |

Round-robin owner assignment is available on HubSpot and Salesforce.

To read data in the other direction, the
[HubSpot MCP tools](https://www.withsurface.com/docs/mcp-server/tools#hubspot) are read-only lookups
against a connected HubSpot account: companies, contacts, open deals, owners,
pipelines and recent activity. See [Lead Data Layer](https://www.withsurface.com/docs/platform/leads).

Related: [HubSpot](https://www.withsurface.com/docs/platform/integrations/hubspot) ·
[Salesforce](https://www.withsurface.com/docs/platform/integrations/salesforce) ·
[Attio](https://www.withsurface.com/docs/platform/integrations/attio) ·
[HubSpot MCP lookups](https://www.withsurface.com/docs/mcp-server/tools#hubspot)
