# Automations

> Make the bot do things on its own with no code. Pick what starts it, add checks, then the actions.

An **automation** is a small flow the bot runs by itself. You build it on a canvas, block by block:

1. **When**: what starts it. For example, a member joins.
2. **If**: optional checks. For example, the account is older than 7 days.
3. **Do**: what the bot does. For example, give a role and send a message.

No code is needed. Open **Automations** on the dashboard.

> **Note:** Automations is a premium feature and is in beta. On the free plan you can see the page, but you can't build or run automations.

> **Tip:** The fastest start is a template. Open **Templates**, pick one, press **Use template**, then fill in the role or channel it asks for.

## Build one

1. Open **Automations** and press **New automation**.
2. Pick a template, or **Start blank** and choose a trigger.
3. Add blocks. Press the **+** under a block to add the next one, or drag one in from the left panel.
4. Click a block to change its settings on the right.
5. Press **Test run** to see the path it would take, without doing anything for real.
6. Press **Publish**. The automation is now live.

Your edits save on their own as a **draft**. The bot only runs the **published** version, so a half-finished change never runs. **Discard** goes back to what is live.

## Triggers

Each automation has one trigger.

| Group | Triggers |
|---|---|
| Members | Joins, leaves, gets a role, loses a role, changes nickname, boosts the server |
| Messages | Sends, edits or deletes a message, mentions the bot, creates a thread |
| Reactions | Adds or removes a reaction |
| Buttons | Clicks a button, picks from a menu, sends a form |
| Voice | Joins, leaves or moves voice channel |
| Other | On a schedule, votes for the bot |

Most triggers can be limited to some channels. Buttons, menus and forms match by their **custom ID**.

### Cooldown

A trigger can have a **cooldown**, so it runs at most once in a while. Pick **per member**, **per channel** or **whole server**, and a time. For example, an auto-reply with a 60-second cooldown per channel answers once a minute, however many people ask.

## Checks (If blocks)

An **If** block checks rules, then goes down **Yes** or **No**.

- **All of these**: every rule must be true.
- **Any of these**: one rule is enough.
- **None of these**: no rule may be true.

Groups can go inside groups, up to 4 deep. Each rule can also be flipped to **is not**.

Rules include: channel or category, roles (any, all or none), specific users, bots, account age, time in the server, boosting, message text (contains, is exactly, starts with, matches a pattern), attachments (image, video, audio, file), replies, mentions, links, message length, the reaction emoji, time of day, day of the week, comparing a value, and random chance.

## Actions

| Group | Blocks |
|---|---|
| Messages | Send a message, send a DM, reply, react, delete, pin, create a thread |
| Members | Give a role (for good or for a while), take a role, set nickname, time out, kick, ban, move or disconnect from voice |
| Channels | Set slowmode, lock, unlock |
| Data | Set a value, do math, save a server or member value |

Messages use the same editor as the rest of the dashboard, with embeds and buttons.

> **Note:** **Give a role** can't give a role with staff permissions, like Administrator or Ban Members. That stops anyone from handing themselves power through an automation.

## Flow blocks

| Block | What it does |
|---|---|
| **Wait** | Pauses, then carries on. For example, remove a role after 1 day. Waits survive bot restarts. |
| **Wait for…** | Pauses until the member replies, clicks a button or reacts. It has a **Timeout** exit for when they don't. The answer is saved, for example as `{var.answer}`. |
| **Random split** | Picks one of 2 to 4 paths at random, by percent. |
| **Stop** | Ends the automation. |
| **Code** | Runs Python with the trigger's data, like an [Event](https://ccbot.app/docs/getting-started/events). Premium. |

> **Watch out:** Discord only lets the bot answer a button click for 15 minutes. In a flow started by a click, a menu or a form, use **Send a message** instead of **Reply** after a long wait.

## Variables

Any text can use variables:

| Variable | Gives |
|---|---|
| `{user.mention}`, `{user.name}`, `{user.id}` | The member |
| `{server.name}` | The server |
| `{channel.mention}`, `{channel.name}` | The channel |
| `{message.content}` | The message text |
| `{var.name}` | A value set earlier in this run |
| `{server_var.name}`, `{member_var.name}` | Values saved on the server or member |
| `{var.choice}`, `{var.choices}` | What was picked in a menu (first pick, or all of them) |
| `{var.field}` | A form field, by the field's custom ID |

Text checks ignore capital letters: "Hello" matches "hello".

## History and errors

**History** lists the last runs: when, who, and how it went. A run where only the checks ran and one said no shows as **Checks said no**; on a busy server, one of those is kept a minute per automation, so History stays useful. Click a run to see the path it took on the canvas. A failed step shows in red with the reason, such as a missing permission.

If an action fails, the run stops there. The automation shows the last error on the Automations page until you publish again.

## Limits

| | Starter | Basic | Advanced |
|---|---|---|---|
| Automations | 15 | 50 | 200 |
| Longest wait | 30 days | 30 days | 30 days |
| Code block | Yes | Yes | Yes |

Every plan: up to 50 steps per run, and loops are not allowed (lines only go forward).

### Automations that set each other off

Messages, reactions and threads the bot makes never start an automation. Changes it makes to a member (a role, nickname, timeout or voice move) can, so two automations could keep answering each other. Two guards stop that:

- **Chain depth.** A run started by another automation's change counts one step deeper. Past 3 steps it doesn't start, and History shows "Stopped: automations keep starting each other".
- **Loop breaker.** If one automation is started that way for the same member more than 5 times in 10 seconds, it is **turned off** and the reason shows on the Automations page. Fix it, then turn it back on.

A member's own activity never counts: someone sending many messages doesn't turn anything off.

## Save your own templates

Open the **⋯** menu in the builder and pick **Save as template**. It appears under **Templates** in every server you manage.
