# Automations

When something happens to a contact, do something - reply to keywords, chase unpaid fees, follow up - with waits in between.

> **In a nutshell:** An automation is a trigger (message received, keyword, contact created, conversation status, a date field), optional conditions (the segment tree) and steps (send a template or text, tag, set status, note, notify your product, wait). Sends go through all the usual checks; conditions are re-checked after every wait.

## Triggers

| Trigger | When | `trigger_config` |
|---|---|---|
| `message_received` | A contact writes in | - |
| `keyword` | A contact's message is exactly one of the keywords (any case) | `{"keywords": ["FEES", "TERM DATES"]}` |
| `contact_created` | A new contact appears (first message, or created by you) | - |
| `conversation_status` | A conversation becomes a status | `{"status": "resolved"}` |
| `date_reached` | A contact's date field is today, plus an offset | `{"field": "fee_due_date", "offset_days": -3}` |

`conditions` is the [segment condition tree](/docs/campaigns): the run only starts if the
contact matches, and stops after a wait if they no longer do - so a fee reminder chain ends as
soon as `fee_balance` is 0.

## Steps

| Step | Does |
|---|---|
| `send_template` | Sends an APPROVED template; `parameters` map variables like campaigns (`field:name`, `custom:<key>`, `text:...`) |
| `send_text` | Sends text - only inside the 24-hour window, otherwise skipped |
| `add_tag` / `remove_tag` | Tags the contact |
| `set_status` | Sets the conversation's status (open, pending, resolved, closed) |
| `add_note` | Adds an internal note to the conversation |
| `notify` | Sends you an [`automation.action`](/docs/api/callbacks/automation-action) callback with the step's `data` |
| `wait` | Waits `minutes`, `hours` or `days`, then re-checks the conditions |

Every send goes through suppression, consent, preferences, limits and quiet hours; a step that
cannot send is skipped with the reason and the run carries on. [List automation
runs](/docs/api/list-automation-runs) shows what each step did.

## Safety

- Nothing an automation does starts automations - no loops.
- Each trigger runs an automation once for a contact, and at most three times a day.
- Pausing an automation stops its waiting runs.
