# Agents & Workflows (/concepts/agents-and-workflows)





A Trelium agent is a workflow that does a job for your team. The workflow is the plan: what starts the job, what the agent does, what it checks, and where a person steps in. The agent is that plan, running. Trelium calls the written version of the plan an agent's **Flow**.

An agent is not a chatbot. You don't type questions to it and wait for a reply. It watches for work and does the job.

## What a workflow is made of [#what-a-workflow-is-made-of]

Every workflow has four parts.

* **A trigger.** What starts a run, such as a customer email arriving or a schedule firing. See [Triggers & Inputs](/concepts/triggers-and-inputs).
* **Steps.** What the agent does, in order: look things up, read a document, apply a rule, prepare a record.
* **Rules.** What the agent checks before it enters anything. See [Validation & Exceptions](/concepts/validation-and-exceptions).
* **Review points.** Where a person looks at a result or approves it. See [Human in the Loop](/concepts/human-in-the-loop).

What the trigger hands the agent, such as the email and its attachment, is the **input**. What the agent produces, such as a draft order or a reply, is the **output**. When a check finds a problem, such as a price that doesn't match, the case is called an **exception**.

Each time the agent goes through the workflow, that is called a **run**. A run can handle a single piece of work, such as one customer email, or several at once. Each run is one row in the agent's [Activity log](/concepts/logs-and-audit-trails), with its steps, status, and the credits it used.

## Fixed steps and AI steps [#fixed-steps-and-ai-steps]

Some steps are fixed. The same input always takes the same path. Looking up an order, comparing a price to the agreed price, and entering a record are fixed steps.

Some steps use AI. These are the steps that need reading and interpretation, such as pulling line items out of a PDF or working out which order an email is about.

<Callout title="AI reads. Rules decide.">
  AI drafts a result. Rules check it. A person reviews anything unclear or risky. That order keeps the unpredictable part in a small, watched place.
</Callout>

## What an agent works with [#what-an-agent-works-with]

Agents work inside the software your team already uses, such as your order system, accounting software, email, spreadsheets, and supplier websites. If a tool offers a built-in connection for other software (called an **API**), the agent can use it. If it doesn't, the agent can work in the tool through a web browser. The agent does not replace any of these tools. Your order system stays your order system. See [Integrations](/concepts/integrations).

<figure style="{ maxWidth: '24rem', margin: '1.5rem auto' }">
    <img alt="The Flow view of an example Trelium agent, showing its steps written as short sentences, from a Slack request to a reply in the same thread." src="__img0" />

  <figcaption style="{ fontSize: '0.875rem', opacity: 0.8, marginTop: '0.5rem' }">
    An agent's Flow: its workflow written out step by step. This agent checks whether a company fits a target customer profile, starting from a request in Slack.
  </figcaption>
</figure>

## Example: entering a purchase order [#example-entering-a-purchase-order]

This example is a PO entry agent. It follows one customer email from start to finish. The full version, with the rules it checks and three example POs, is the [Purchase Order Entry](/recipes/purchase-order-entry) recipe.

<Mermaid
  chart="
flowchart LR
A[Customer email<br/>with PO arrives] --> B[Read the PO] --> C[Look up customer,<br/>items, and prices] --> D{Check against<br/>your rules}
D -->|All match| F[Create sales<br/>order draft] --> G[Log the run]
D -->|Something is off| E[Person reviews<br/>flagged lines] --> F
classDef ai stroke:#7c3aed,stroke-width:3px
classDef person stroke:#d97706,stroke-width:3px
class B ai
class E person
"
/>

The purple step uses AI. The orange step is where a person steps in, and only some runs take that path.

A PO arrives as an email with an attachment. The agent reads it and pulls out the customer, the items, the quantities, and the prices. It looks up each item and checks the prices against what was agreed with that customer. If everything matches, it creates a sales order draft in the order system. If something is off, such as a price below the agreed price, the agent sends the flagged lines to a person first. Every run is logged either way.

## Where to go next [#where-to-go-next]

<Cards>
  <Card title="How Trelium Works" href="/how-trelium-works">
    The stages of a job, from start to finish.
  </Card>

  <Card title="Choosing a Workflow" href="/concepts/choosing-a-workflow">
    Pick a good first job.
  </Card>

  <Card title="Human in the Loop" href="/concepts/human-in-the-loop">
    Where people review and approve.
  </Card>

  <Card title="Triggers & Inputs" href="/concepts/triggers-and-inputs">
    What starts a run and what the agent works on.
  </Card>
</Cards>
