# Automations

An automation is one saved graph: a trigger, the steps after it and the links between them. It is created switched off unless you ask otherwise, checked with `validate_automation`, and switched on with `activate_automation`.

## Pick how to build it

| The idea | Call | Notes |
|---|---|---|
| A ready-made one fits | `install_automation_template` with `templateId` and `fields` | `list_automation_templates` finds it by words and channel; `get_automation_template` lists its `inputs`. |
| Plain words | `create_automation` with `name` and `request` | Saved on the `quick` start (`inbound_message` unless sent), then built from the words. `stepEdits` says what it made and what it could not. |
| Comment to DM | `create_automation` with `quick: "comment"` | See [Comment to DM](comment-to-dm.md). |
| A word in a DM gets one reply | `create_automation` with `quick: "inbound_message"`, `keywords`, `dmMessage` | A draft unless `status: "active"`. |
| Messages on a timer | `create_automation` with `steps` | Each step waits `after` the one before; a reply or an unsubscribe ends a contact's run unless `limits.stopOn` says otherwise. |
| Anything else | `create_automation` with `graph` | See [Workflows](workflows.md). |

## Read the catalog in parts

`get_automation_catalog` says what any automation is built from. The whole index is large, so read the part you need with `part`:

| `part` | Holds |
|---|---|
| `starts` | `kinds` and `triggers`: every trigger, the steps that may follow it, its facts and filter operators |
| `steps` | Every step with its exits, outputs and channels |
| `rules` | `operators`, `keywordModes`, `durations`, `triggerLimits`, `limits` |
| `schema` | The JSON Schema of `create_automation`'s body |
| `templates` | The ready-made automations in brief |

One row's settings: `list_automation_blocks` with `filter=key:eq:<key>&include=input,definition`.

## Check, test, switch on

1. `validate_automation`: what it does, who it reaches, and anything that `blocksPublish`.
2. `test_automation`: walks the draft with a sample (`text`, `channel`, or an `event`). Nothing is sent or stored.
3. `activate_automation`: only on the person's word. `get_automation` then shows `status: active`.

## Keep it as your own template

`create_automation_template` with `from: {automationIds: [id]}` and a `name` saves it as the brand's own template, without any key or password. It installs again with `install_automation_template`, like a ready-made one.

## What is refused

A step whose area is not offered to the brand is refused at the save, with the step named at its path (`graph.nodes.<n>.type`). Ask `list_automation_blocks` for what the brand can use.
