# Automations

An automation starts a chat in a [space](/docs/spaces/) for you, from a **Schedule**, which runs at set times, or a **Webhook**, which runs when another app sends an event. Each one has instructions, an agent and one trigger.

<Screenshot
  shot="automations/schedules"
  alt="The Automations page on the Schedules tab with schedules across four spaces, each with its frequency, next run and status"
  caption="Automations, with the schedules of every space."
/>

**Automations** in the sidebar lists the automations of all your spaces, on a **Schedules** tab and a **Webhooks** tab. Each space also has its own **Automations** page.

## Create an automation

<Steps>

1. Select **New automation**, and pick the space.
2. Name it, and write the instructions: what the agent should do each time it runs.
3. Pick the agent. Without one, Ren runs it with the space's settings, then the organization's, then Ren's defaults.
4. Select **Add trigger** and pick **Schedule** or **Webhook**. **From an app** turns on a webhook that one of the space's [apps](/docs/apps/) offers, with its instructions already written.
5. Select **Save**, then **Test** to run it once now.

</Steps>

Use the switch in the header to turn it on or off. **Duplicate** and **Delete** are in `⋯`. Deleting an automation stops its trigger. The chats it started stay.

## Schedules

Pick how often it runs: **Hourly**, **Daily**, **Weekdays**, **Weekly**, **Monthly**, **Once** on a date, or **Custom (cron)**.

Under **Advanced**, set the time zone, which starts as your browser's, and an end date.

Each run starts a new chat. If you ask Ren in a chat to run something on a schedule in that chat, **Each run** shows **Goes to one chat**. Select **Start a new chat instead** to change it.

A space can have 50 active schedules, each at least 5 minutes apart.

## Webhooks

A webhook is a URL that another app sends requests to, such as Stripe on a failed payment or Linear on a new issue. Each request it accepts starts or continues a chat.

### Set up a webhook

<Steps>

1. Save the automation to get its URL, then select **Requests, filter and signature**.
2. Copy the URL into the other app. It holds a token, so treat it like a password.
3. If the other app signs its requests, set the [signature](#signature).
4. Send a test event from the other app. It shows under **Requests**.
5. Switch it from **Debug** to **Live**. **Debug** only records requests. **Live** runs the agent on them.

</Steps>

### Signature

Pick the check that the other app supports:

| Check                        | Use it for                                |
| ---------------------------- | ----------------------------------------- |
| **URL only**                 | Apps that cannot sign requests            |
| **Header equals the secret** | Apps that send a fixed secret in a header |
| **HMAC of the body**         | Apps that sign the body, such as GitHub   |
| **Standard Webhooks**        | Svix, Clerk, Resend                       |
| **Stripe**                   | Stripe                                    |

Select **Set secret**. Ren makes a secret and shows it once, or you paste the one the other app gave you. **Live** stays off until the secret is set.

### Which requests run the agent

| Setting                      | What it does                                                                  |
| ---------------------------- | ----------------------------------------------------------------------------- |
| **Start a session when**     | A condition, such as "the action is create". Other requests are ignored.      |
| **Session continuation key** | A value, such as an issue ID. Requests with the same value continue one chat. |
| **Event identifier**         | A delivery ID. Ren skips a request it has already seen.                       |
| **Session title**            | A value that names the chat, such as the issue title.                         |

To set one, open a recorded request, select a value in its body, and pick what to use it for. Then select **Save**. **Check** tests the rules on the last 20 requests.

<Screenshot
  shot="automations/request-menu"
  frame="detail"
  alt="The body of a recorded Linear request with the issue title selected and a menu with Add as condition, Use as session continuation key and Use as session title"
  caption="Select a value in a recorded request to use it."
/>

Rules are [CEL](https://cel.dev) expressions.

### Requests

The webhook lists its requests from the last 30 days, with their outcome:

| Outcome   | Meaning                                          |
| --------- | ------------------------------------------------ |
| Queued    | Waiting to run.                                  |
| Started   | It started a chat.                               |
| Continued | It continued a chat.                             |
| Recorded  | Kept without a run: the webhook is in **Debug**. |
| Ignored   | The condition was false, or a rule failed.       |
| Duplicate | Ren saw its event identifier before.             |
| Rejected  | Wrong or missing signature, or a body over 1 MB. |
| Throttled | Over 60 requests in one minute.                  |
| Failed    | The agent could not take it.                     |
| Answered  | A URL check from the other app.                  |

Select **Replay** to run the queued, recorded, throttled and failed requests. The webhook must be **Live**.

When the URL leaks, select **Rotate URL** and paste the new one in the other app.

## Run history

Select **Run history** on an automation to see each run from the last 30 days. Select a run to open its chat beside the list, and reply to continue it.

## Needs attention

Ren stops an automation and marks it **Needs attention** when it cannot run as set up:

| Cause                                                | Fix                                                         |
| ---------------------------------------------------- | ----------------------------------------------------------- |
| A schedule's owner left the space                    | Save it to run it as you                                    |
| A webhook's owner and fallback user left the space   | It switches to **Debug**. Turn it **Live** to run it as you |
| Its agent left the space                             | Pick another agent                                          |
| The last 5 runs failed, such as when credits ran out | Open the failed runs, fix it, turn it on                    |
| A webhook's rule broke on 5 requests in a row        | Fix the rule, then turn it **Live**                         |
| The app no longer offers the webhook                 | Delete it                                                   |

<Screenshot
  shot="automations/webhook-warning"
  frame="detail"
  alt="The Webhooks tab with Stripe failed payments marked Needs attention and Linear new bugs marked Active"
  caption="A webhook that needs attention."
/>

After you fix a webhook, select **Replay** to run the requests it recorded meanwhile.

## Who an automation runs as

An automation runs as its owner: the last person who changed what it does, such as its instructions, agent, schedule or rules. Any member of the space can manage its automations.

For a webhook, **If the owner leaves the space** under **Advanced** decides what happens: **Switch it to Debug**, **Run it as me**, or run it as another member.

A chat from an automation has nobody to approve a permission card, so actions that ask first are denied. Allow what it needs in [permissions](/docs/permissions/).