Define automation rule
define_automationCreate an automation rule: when trigger_event fires (record.written) and condition_spec matches, run action_tool with action_args (a {{placeholder}} template over the trigger facts). The action re-enters the governance chokepoint, so it still respects approvals + write-scope. Requires the workspace automation flag to actually fire. Returns the rule. An existing rule is edited with update_record / delete_record on object_type "automation" (its id and key come from describe_schema).
When to use: When an admin wants an action to fire automatically on a record write — e.g. flag big deals, create a follow-up task.
Example: When an opportunity over $100k is created, make a task for me to review it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| label | Yes | Display name for the rule. Its slug becomes the rule key, which must be unique in the workspace. | |
| action_args | No | Arguments for action_tool. String values may embed {{object_key}}, {{tool_name}}, {{record_id}} or {{account_id}}; a whole-string placeholder keeps the fact's raw type. | |
| action_tool | Yes | The registered tool to run, by name (e.g. create_record, add_note). Account-creating actions (create_account, migrate_crm, create_record of account) are refused. | |
| trigger_event | No | The event that fires the rule. Only "record.written" (any governed record write) exists today; it is the default. | |
| condition_spec | No | all (AND) / any (OR) lists of {field, op, value?} on object_key, tool_name, record_id, account_id; op eq/neq/gt/gte/lt/lte/contains/in/is_null/is_not_null. {} = every write. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| automation | No |