> This is a page from the ElevenLabs documentation. For an index of the documentation, fetch https://elevenlabs.io/docs/llms.txt.

# Build a routine

A routine is a flow of steps that runs in the background when a conversation ends, on a schedule, or when another system sends a webhook. To build one, choose a trigger, connect steps after it, and set what each step reads and where the run goes next.

> **Info**
>
> Routines are in beta and not yet available in every workspace. To request access, contact your
> account manager.

## Create a routine

#### Create the routine

Open **Routines** in the ElevenAgents sidebar and select **New routine**. New routines start
with a **Manual run** trigger.

![Routines page with the New routine button and the list of routines](/docs/_fern-files/_img/463c4d38169daad277a07be8977029f54b70e229018a44d781fe016488329b6d.webp)

#### Choose the trigger

Select the trigger to change its type, or keep **Manual run** while you build. See
[Triggers](/docs/eleven-agents/operate/routines/triggers).

#### Add steps

Select **Add step** in the toolbar, or the **+** under a step to add one right after it, and
choose a step type. Select a step to open its settings.

![Step type menu opened from the + under a step on the canvas](/docs/_fern-files/_img/a1c5b40479c45c0953ae6d97f25e411c921fa47228a8d7f7f1ff23f0c7c468ef.webp)

The editor saves the draft as you work. Only test runs use the draft until you [publish it](/docs/eleven-agents/operate/routines/test-and-publish).

> **Tip**
>
> You can also build a routine with [Architect](/docs/eleven-agents/operate/architect). Describe
> what it should do, and Architect writes the steps into the draft, runs tests, and publishes it
> with you. It asks for your approval before actions like placing real calls or publishing.

## Pass data between steps

Each step lists the inputs it needs under **Inputs**. Set each one to a fixed value, or pick a field from the trigger, an earlier step, or a variable. For example, an HTTP request step named `lookup_customer` can take `customer_id` from the trigger, and a later step can read `lookup_customer.body.tier` from its response.

![A step's inputs, with the picker of earlier step outputs and variables
open](/docs/_fern-files/_img/5c73ce2a7f7ade241b2dd5a2203f8b4ac38abda8bbac258011606eea46170256.webp)

### Variables

**Variables** are named values that any step later in the run can read, such as a customer ID that several steps need. Add them in the routine's **Variables** panel, with a type (string, number, or boolean) and a default. To fill a variable, select the `{}` button next to any trigger field or step output, then name a new variable or pick one the routine already has.

![Variables panel with four string variables](/docs/_fern-files/_img/827358a4a1c3e45bc3156dd0b42b3c5e45e70c10b44684bda7b0df2f270c09ae.webp)

## Branch with conditions

A connection between two steps can carry a condition. After a step finishes, the run follows every connection whose condition holds, so two matching branches run in parallel.

| Connection       | Followed when                                                                                           |
| ---------------- | ------------------------------------------------------------------------------------------------------- |
| **No condition** | Always.                                                                                                 |
| **Condition**    | Its expression holds, such as `lookup_customer.body.tier` equals `vip`. A value that isn't set is null. |
| **Fallback**     | None of the step's other conditions hold, like an *else*. A step can have one fallback.                 |

![A connection's condition, lookup\_customer.body.tier equals
vip](/docs/_fern-files/_img/eff02544f859f165663cb28868f850cea0a1188ea7cdd55766cd202912c95432.webp)

A branch with no matching connection ends there, and the run still succeeds. A step that several branches lead to runs once, after all of the branches that reach it have finished.

> **Warning**
>
> Two cases fail a run where branches meet: both branches set the same variable, or the step reads
> an output from a branch the run didn't take.

## Handle failures

A step fails when its retries run out, when it gets an error that isn't retried (such as an HTTP 4xx response), or when one of its inputs can't be resolved. By default, a failed step fails the whole run.

Add an **error connection** from a step to run cleanup when it fails, such as posting an alert. Steps on an error path can read the failure as `error`:

```json
{
  "message": "HTTP 404: {\"detail\": \"Customer not found\"}",
  "step": "Look up customer",
  "attempts": 1
}
```

> **Note**
>
> A run whose step failed still ends as failed, even when an error connection handles it. Use error
> connections to notify or clean up, not to recover.

Each step's **Retry** settings control how many attempts it makes, with exponential backoff between them. Outbound call steps never retry, so a retry can't dial the same number twice.