# Build an agent

Create an agent or edit one, field by field, then test it and set it to Active.

You build and edit agents in the agent editor. This page goes through each field, then how to test the agent and turn it on. If you'd rather start from something that works, open one of the starter agents and change it instead.

## New agent or existing agent

The editor looks the same in both cases, with one difference:

- **The New agent page.** On the **Agents** page, select **New agent**. The test panel is off here and says **Save the agent before running a test.** When you select **Save changes**, APX creates the agent and opens its page.
- **An agent's page.** On the **Agents** page, select any agent. The top bar shows its name, status and version, and the test panel on the right is ready to use.

On a wide screen the fields are on the left and the test panel stays in view on the right. On a narrower screen, such as a tablet or phone, the test panel sits below the fields.

## Agent

| Field | What to enter |
|---|---|
| **Name** | What you'll see on calls and in alerts. Required. |
| **Description (optional)** | A line about what the agent does. It shows under the name on the **Agents** page. |
| **Category** | **Sales Coaching**, **Compliance**, **Customer Service**, **Quality Assurance** or **Custom**. A label to help you tell agents apart. New agents start as **Custom**. |
| **Status** | **Draft**, **Active** or **Archived**. New agents start as **Draft**. See [Statuses](/docs/agents/overview#statuses). |
| **Flag below score** | A number from 0 to 100. **Calls below this score get flagged.** New agents start at 70. Leave it empty if you don't want this agent to flag calls. |

Under **Flag below score**, the editor shows where this agent's alerts go, for example **Alerts go to** followed by an email address or Slack channel. If it says **Alerts for this agent have nowhere to go**, the agent can flag calls but no one hears about it. [Alerts](/docs/alerts/overview) explains how to route them.

## Prompt

The prompt tells the agent how to think: who it is (a sales coach, a compliance analyst), what matters most, and how strict to be. As the editor puts it: **Tell the agent how to think. The criteria below feed into this prompt automatically.** So you don't need to repeat the criteria here.

The prompt needs at least 20 characters. [Write good instructions](/docs/agents/writing-good-instructions) has patterns that work.

## Criteria

Criteria are the things the agent looks for. Each one is graded separately and shows up in the breakdown on every analysis.

1. Type the criterion in the box at the bottom (it says **Add a thing to look for…**), for example "Confirmed the customer's account before making changes".
2. Select **Add**, or press Enter.
3. To fine-tune it, select the arrow next to the criterion. This opens three more settings:

| Setting | What it does |
|---|---|
| **How to grade** | **Yes / No** (met or not met), **Rate 1–5**, **Rate 1–10**, **Percentage** or **Note only**. New criteria start as **Yes / No**. |
| **Weight (1–10)** | How much the criterion counts towards the overall score. Higher weights count for more. |
| **Description (optional)** | Extra detail on what good looks like for this criterion. The agent reads it. |

To remove a criterion, select the X icon next to it. Put the most important criteria first; you can add up to 50.

> **Note:** An agent needs at least one criterion before you can set it to **Active**.

## Save your changes

Select **Save changes** at the top right. The button shows **Saved** for a moment when it's done.

Saving a change to the prompt or criteria creates a new version of the agent, and the version number next to its name goes up (**v2**, **v3** and so on). Calls already scored keep the score from the version that scored them. Changing the name, description, category, status or threshold doesn't create a new version.

If someone else saved the same agent while you were editing, APX shows **Someone else changed this agent**. Select **Reload to see latest** to load their version. Your unsaved edits are replaced, so copy anything you want to keep first, then make your changes again and save. **Discard my changes** only closes the message: your edits stay on screen, but they can't be saved until you reload.

## Test it

Once the agent is saved, use the **Test against transcript** panel to run it on a sample call or a transcript you paste. Tests run the last saved version, so save before you test. [Test an agent](/docs/agents/testing-an-agent) covers reading the result.

## Turn it on

1. Set **Status** to **Active**.
2. Select **Save changes**.

From now on the agent scores every new call it runs on. APX also goes back and scores the calls from the last 24 hours that this agent would have run on, so you don't have to wait for new calls to see results. Saving a new version of an active agent does the same, so recent calls get scored with the new version too.

By default an agent runs on every call. To narrow it down, see [Call types](/docs/agents/call-types).

## Troubleshooting

| What you see | What to do |
|---|---|
| **Add at least one criterion before activating.** | Add a criterion under **Criteria**, then save again. |
| **Cannot activate an agent with no criteria** | The same thing on the **New agent** page. Add a criterion, or save as **Draft** first. |
| An error about the prompt when you save | The prompt is too short. Write at least a sentence. |
| **Couldn't load this agent.** | The agent may have been deleted. Go back to **Agents** and check the list. |
