# Automation

URL: https://zerodev.ca/docs/medusa/paid-modules/automation

> Build your own commands and workflows from blocks on a canvas.



Automation lets you build features without code. A flow starts with a trigger, such as a slash command, a member joining or a schedule, then runs checks and actions you connect on a canvas. Build flows on the dashboard **Automations** page.

## How a Flow Runs

1. **Trigger**: what starts the flow. A command, a Discord event, a schedule, a webhook, a button, a menu or a form.
2. **Checks**: blocks that decide where the flow goes next, such as Condition, Has Role or Cooldown.
3. **Actions**: what the flow does, such as sending a message, giving a role or calling an API.

Text in any block can use placeholders like `%user%`, `%channel%` and `%server%`, plus values set earlier in the flow.

## The Editor

* **Automations page**: stats, Active and Disabled filters, and a card per flow showing its triggers, last run and bot. Each card can be duplicated, copied to another server, exported or deleted.
* **Blocks panel**: blocks grouped by category. Click one to add it, or drag it into place. Other modules add their own blocks, such as Economy's Add Coins.
* **Header**: rename the flow, turn it on or off, see problems such as a missing trigger, open Runs and Flow Settings, tidy the layout and save. Flows save themselves every 30 seconds.
* **Runs**: the last 25 runs with their status, steps, time taken and any error. Opening a failed run highlights the block that failed.
* **Test Run**: Schedule and API Endpoint flows can be run once from the editor.

## More Than One Bot or Server

* **Flow bot**: with several bots, pick which bot registers the flow's commands, listens for its events and sends its messages in **Flow Settings**.
* **Switch Bot** block: run the rest of a flow as another bot.
* **Other servers**: Channel, Route Channel and Role blocks can target another server, **Switch Server** moves the rest of the flow to another server, and **Member In Server** checks membership elsewhere. Saving checks that you manage every server a flow uses.
* **Copy to Server**: copy a flow to another server; channels, roles and categories are matched by name.

## Import and Export

Export one or more flows as a JSON file, and import that file on another server or install.

## Blocks

<Tabs items="[&#x22;Triggers&#x22;, &#x22;Logic&#x22;, &#x22;Actions&#x22;, &#x22;Values & Data&#x22;]">
  <Tab value="Triggers">
    * **Slash Command**, subcommands, subcommand groups and typed options.
    * **Context Menu** on users or messages.
    * **Discord Event**: members joining, leaving, updating or being banned; messages sent, edited or deleted; reactions; channels, threads, roles and invites; voice changes. Filter by channel, message text and bots.
    * **Reaction** and **Voice Activity** triggers.
    * **Schedule**: presets or a custom cron schedule with a time zone.
    * **API Endpoint**: `/api/modules/automation/hooks/<path>`, with an optional API key and IP allow list.
    * **Buttons, Select Menus and Modals**. Modals hold up to five entries: text inputs, select menus, pickers and text displays that show extra information above or between the fields.
  </Tab>

  <Tab value="Logic">
    * **Condition**: equals, contains, starts or ends with, numeric comparisons, empty checks and regex.
    * **Has Role**, **Has Permission** and **Member In Server** checks.
    * **Cooldown** per user, channel or server.
    * **Loop** over a count or a list, **Chance**, **Random Choice** and **Logic Gate**.
    * **Delay / Wait**, **Run Flow** and **Stop Flow**.
  </Tab>

  <Tab value="Actions">
    * **Embed** and **Send Message**, including saved messages from the Embeds page.
    * **Direct Message**, **Add Reaction**, **Message Action** (delete, pin, publish, clear reactions).
    * **Create Thread** and **Create Channel**, which can receive the next messages.
    * **Role** add, remove or toggle, and **Member Moderation** (timeout, kick, ban, softban, nickname).
    * **API Request** with success and error branches.
  </Tab>

  <Tab value="Values & Data">
    * **Set Variable**, **Random Number**, **Text Template**, **Math Operation**, **Array** and **JSON** values.
    * **Datastore** set, get, adjust and delete for per-server key-value storage.
  </Tab>
</Tabs>
