> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/documentation/action-center/rules-and-triggers.md).

# Rules and Triggers

Build an Action Center workflow: choose when it starts (Manual, Scheduled or Event Based), add conditions and jobs, and control which assets each job receives.

An Action Center workflow starts from a trigger, optionally checks a condition against a saved query, and then runs jobs such as sending a Slack message, opening a Jira issue or contacting a webhook. This page covers how to create a workflow, every trigger type, how nodes are chained, and what each job receives.

{% hint style="info" %}
The console uses the terms **Workflow**, **Trigger** and **Job**. There is no "rule" object in Action Center, so this page uses the console terms.
{% endhint %}

### Before you begin

* Required permissions: `workflows.add_workflow` and `workflows.change_workflow` to create and edit, `workflows.run_workflow` to run a workflow by hand, `workflows.delete_workflow` to delete.
* At least one completed discovery. A workflow always works on the latest completed discovery; without one it stops with the log message "No discovery found."
* Credentials for the target system (a Slack webhook URL, a Jira API token, and so on). You can enter them in each job, or store defaults once in Action Center Settings.
* A saved query, if you want to act on specific assets. See Create and Save Queries.

### How a workflow is built

A workflow is a graph on a canvas with three kinds of node:

| Node          | What it does                                                                                                                                            | How you add it         |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- |
| **Triggers**  | Decides when the workflow starts. Every workflow has exactly one; it is already on the canvas and cannot be deleted or duplicated.                      | Present by default     |
| **Condition** | Runs a saved query and compares the result with a value. Its result decides which edge to follow, and its matching assets are handed to the next nodes. | **Add Condition Node** |
| **Job**       | Performs one action in an integration, for example **Send Notification** on Slack.                                                                      | **Add Job Node**       |

Nodes are joined by arrows (edges). The edge type is set automatically by the node it leaves:

| Edge leaves from | Edge label            | Meaning                                                                                                                                     |
| ---------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| Triggers         | `START`               | First node(s) to run when the trigger fires.                                                                                                |
| Job              | `NEXT`                | Run the next node after this job finishes.                                                                                                  |
| Condition        | `SUCCESS` or `FAILED` | You pick the status when you draw the arrow (**Select Edge Status**). `SUCCESS` runs when the condition is true, `FAILED` when it is false. |

The Triggers node cannot be the target of an arrow, and a node cannot connect to itself.

#### Canvas toolbar

The toolbar above the canvas has five icons. Hover over an icon to see its name.

| Icon tooltip           | What it does                                                                                                                    |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| **Basic Info**         | Opens the **Basic Info** dialog with **Title** and **Description** (both required).                                             |
| **Add Condition Node** | Adds a Condition node.                                                                                                          |
| **Add Job Node**       | Opens the **Add Job Node** drawer, where you pick a job.                                                                        |
| **Edit Columns**       | Chooses which columns each asset type contributes to job output (mail tables, Slack text, Jira descriptions, webhook payloads). |
| **Save**               | Opens **Basic Info**; confirm with **Create** (new workflow) or **Save** (existing workflow).                                   |

### Create a workflow

{% stepper %}
{% step %}

#### Open the Create Workflow page

Go to **Action Center** and select **Create Workflow**. The canvas opens with a **Triggers** node. The trigger defaults to **Manual**.
{% endstep %}

{% step %}

#### Choose a trigger

Use the drop-down on the **Triggers** node. See Trigger types for what each option does.
{% endstep %}

{% step %}

#### Add a condition (optional but usually needed)

Select **Add Condition Node**, open the node, and set the query, function, operand and value (see Conditions). Draw an arrow from **Triggers** to the condition.
{% endstep %}

{% step %}

#### Add job nodes

Select **Add Job Node**, filter by integration or type in **Search jobs...**, and select a job. A form titled **Edit {job} Integration** opens. Choose the asset types the job should act on and fill in the fields, then select **Save**. Draw an arrow from the condition (choose `SUCCESS` or `FAILED`) or from another job to the new job.
{% endstep %}

{% step %}

#### Select the columns to report

Select **Edit Columns** and add the columns you want per asset type. Each job also adds the columns it requires on its own.
{% endstep %}

{% step %}

#### Name and save the workflow

Select **Save**, enter a **Title** and **Description**, and select **Create**. If a node has a validation problem, the page shows "Error occurred on creating workflow. Please check nodes marked with red." and marks the nodes.
{% endstep %}
{% endstepper %}

### Trigger types

The **Triggers** node first asks for a type: **Manual**, **Event Based** or **Scheduled**. The workflow list shows the stored value in the **Trigger** column (`manual`, `scheduled`, `pre_discovery`, `post_discovery`, `post_discovery_error`).

| Trigger                               | What fires it                                                                        | Options                                            |
| ------------------------------------- | ------------------------------------------------------------------------------------ | -------------------------------------------------- |
| **Manual**                            | You, with the run (play) button on the workflow list. Nothing runs it automatically. | None.                                              |
| **Scheduled**                         | A timer: the workflow runs at the chosen start time on each selected weekday.        | **Start Time** and **Every x day(s)** (see below). |
| **Event Based: Pre Discovery**        | The start of a discovery, after connections are queued, before data is collected.    | None.                                              |
| **Event Based: Post Discovery**       | A discovery that finishes successfully.                                              | None.                                              |
| **Event Based: Post Discovery Error** | A discovery that ends with an error.                                                 | None.                                              |

When you choose **Event Based**, a second drop-down appears with the three events and **Pre Discovery** is preselected.

#### Scheduled options

| Field              | Description                                                                                             |
| ------------------ | ------------------------------------------------------------------------------------------------------- |
| **Start Time**     | Time of day the workflow starts (hour and minute).                                                      |
| **Every x day(s)** | Weekdays to run on. Pick one or more of Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday. |

A scheduled workflow needs both fields, otherwise saving fails with "Invalid scheduler." The schedule is stored as a recurring task with minute and hour from **Start Time** and the selected weekdays. It is switched on and off together with the workflow's **Active Status**.

#### Event Based details

* Event based workflows run only when **Active Status** is on.
* They run as the built-in `system` user, which is what **Triggered By** shows in the history.
* The Post Discovery Error trigger is the one to use for "tell me when a discovery fails" workflows. A workflow does not receive the failed discovery's data: every run uses the latest completed discovery.

### Conditions

A Condition node counts or measures the assets that match a saved query, then compares the result with a number.

| Field               | Options                                                                                              |
| ------------------- | ---------------------------------------------------------------------------------------------------- |
| Inventory and query | Choose the inventory type, then a saved query.                                                       |
| **Function**        | `count`, `avg`, `max`, `min`, `sum`, `percentage`, `change_percentage`, `abs_change_percentage`      |
| **Operand**         | Equal (`==`), Greater Than (`>`), Greater Than Equal (`>=`), Less Than (`<`), Less Than Equal (`<=`) |
| **Column**          | Required for `avg`, `max`, `min` and `sum`. Hidden for the other functions.                          |
| **Value**           | A whole number to compare against. Default `0`.                                                      |

What the functions return:

* `count`: number of assets matching the query.
* `percentage`: matching assets as a percentage of all assets of that type.
* `change_percentage`: percentage change in the match count compared with the previous completed discovery. Positive means more matches. If there is no previous discovery, the condition is treated as false.
* `abs_change_percentage`: the same value without its sign.
* `avg`, `max`, `min`, `sum`: calculated over the selected **Column** for the matching assets.

If the comparison is true, the `SUCCESS` arrows run; otherwise the `FAILED` arrows run. A condition does not stop the workflow by itself: if you draw no arrow for the outcome, nothing further happens.

### How assets reach a job

Jobs do not run queries. They act on the assets handed to them by the node before them.

1. When the trigger fires, the workflow starts with no assets.
2. A Condition node runs its saved query against the latest completed discovery and adds the matching assets (all of them, not only the count) to what it passes on. Only the columns chosen in **Edit Columns**, plus the columns the connected jobs require, are fetched.
3. A job receives those assets and a job's **asset types** list (shown as an inventory selector at the top of the job form) decides which asset types it uses. The default is `device`.
4. When a job finishes it passes its assets to the job connected by a `NEXT` arrow.

{% hint style="warning" %}
A job connected straight to the Triggers node receives no assets, so a mail would show a count of zero and a Jira or Slack message would have no rows. Put a Condition node in front of any job that should report or act on assets.
{% endhint %}

Some jobs use only assets that have specific columns filled in (for example Slack **Create Channel** needs the Slack user ID). Assets without the required value are skipped.

### Compare jobs

The **Compare** jobs reduce the assets to what changed since an earlier discovery. They must be connected directly after a Condition node, because they compare the condition's query results. If they are not, the job is skipped and the log says "It must be connected to condition node."

| Job                             | Compares with                               | Fields (defaults)                                                                 |
| ------------------------------- | ------------------------------------------- | --------------------------------------------------------------------------------- |
| **Compare With Day**            | The completed discovery from x days ago.    | `direction` (`Added` or `Removed`, default `Added`), `compare_day` (default `1`)  |
| **Compare With Date**           | The completed discovery on a specific date. | `direction`, `compare_date`                                                       |
| **Compare With Last Discovery** | The previous completed discovery.           | `threshold_percentage` (default `0`): skip if the change is below this percentage |

Each asset that passes on is marked with a `compare_status` value: `new_machine` or `parameter_added` for added assets, `removed_machine` or `parameter_removed` for removed ones. If no discovery matches the day or date, the compare job is skipped with a warning and the assets pass on unchanged.

### What job output contains

There is no template or variable syntax in job fields: text you type into a field is sent as is. What each job adds on its own comes from the workflow and the assets:

| Source                        | Used by                                                                                                                                          |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| Workflow **Title**            | Mail subject (default `OctoXLabs {title}`), Slack pretext, Teams subtitle, Jira summary, attachment file names, webhook `name`.                  |
| Workflow **Description**      | Mail header, Slack text, Jira description, webhook `description`.                                                                                |
| Asset count per type          | Mail, Slack, Teams, webhook `count`.                                                                                                             |
| Columns from **Edit Columns** | Table headers and cells in mail, Slack, Teams, Jira and webhook. Multi-value fields are joined with commas; an empty value is written as `null`. |
| Trigger type                  | Webhook `event` (for example `post_discovery`).                                                                                                  |

### Activate, deactivate and run

* **Active Status** on the workflow list is a switch. New workflows are active. Turning it off stops event based and scheduled runs, and pauses the schedule. The console confirms with "Workflow {title}'s status set Disabled".
* To run a workflow now, select the play button in its row. The console confirms with "Workflow {title} has been run". A manual run does not check **Active Status**, so you can test an inactive workflow.
* To see results, open **Action Center** history. The list shows #, workflow title, **Triggered By**, **Status**, start time and end time; open a run for its **Audit Logs** and **Error Details**.

### The workflow list

| Column            | Meaning                                                                                             |
| ----------------- | --------------------------------------------------------------------------------------------------- |
| **Title**         | Workflow name. Search matches title and description.                                                |
| **Description**   | Workflow description.                                                                               |
| **Trigger**       | `manual`, `scheduled`, `pre_discovery`, `post_discovery` or `post_discovery_error`.                 |
| **Scheduled**     | Yes when the trigger is `scheduled`.                                                                |
| **Active Status** | Switch that enables or disables the workflow.                                                       |
| **Actions**       | Edit, delete and run. The **Actions** menu above the table offers export of the selected workflows. |

### Jobs by integration

The **Add Job Node** drawer groups jobs by integration. This is the list captured on a demo console; your version may show more or fewer groups. Jobs marked "per asset" create one item for every matching asset instead of one for the whole set.

| Integration              | Jobs                                                                                                                                                                     |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| General                  | Send Mail, Run Webhook                                                                                                                                                   |
| Compare                  | Compare With Day, Compare With Date, Compare With Last Discovery                                                                                                         |
| OctoXLabs                | Create Notification                                                                                                                                                      |
| Slack                    | Send Notification (incoming webhook); Send Direct Message to a User; user, group and channel management jobs (some require Slack Enterprise)                             |
| Microsoft Teams          | Send Notification                                                                                                                                                        |
| Jira                     | Create Issue/Ticket on Jira Cloud or Self-Hosted (and "Per Asset" versions); Create, Update or Delete Insight Asset Per Asset; Create or Delete User; Create Jira Assets |
| Linear                   | Linear Create Task                                                                                                                                                       |
| Github                   | Create Issue on Github, Update Issue on Github                                                                                                                           |
| Service Now              | Create Service Now Task                                                                                                                                                  |
| ManageEngine ServiceDesk | Service Desk Request                                                                                                                                                     |
| BMC FootPrints           | Ticket, item and contact jobs, including per-asset variants                                                                                                              |
| Xurrent                  | Create Request (formerly 4Me)                                                                                                                                            |
| Microsoft Dynamics 365   | Create Case                                                                                                                                                              |
| OpenText SMAX            | Create Incident, Create Service Request, Create Change, Create or Update Entity                                                                                          |
| MobileITM                | Send Alert to Devices                                                                                                                                                    |
| Tenable                  | Scan, agent, asset, tag, user and group management jobs                                                                                                                  |
| CrowdStrike              | Contain Host, Lift Containment, Hide Host, Unhide Host, Add to or Remove from Host Group                                                                                 |
| SentinelOne              | Disable Agents, Enable Agents, Initiate Scan, Send Message to Agents, Start Network Discovery, Add or Remove Tags                                                        |
| Okta                     | User lifecycle, group, application and factor jobs                                                                                                                       |
| Google Workspace         | User, group, role and membership jobs                                                                                                                                    |
| Google Cloud             | Compute Engine, IAM service account, Cloud SQL and Cloud Functions jobs                                                                                                  |
| AWS                      | EC2, IAM, S3 and SSM jobs                                                                                                                                                |
| Microsoft Azure          | Create Azure Tag                                                                                                                                                         |
| SharePoint               | Create, Update, Delete and Bulk Create Item In List; Delete Users Sites Permissions                                                                                      |
| Wasabi                   | User, group and policy jobs                                                                                                                                              |
| Hetzner                  | Power Off, Power On, Reset and Shutdown Server                                                                                                                           |
| Docker                   | Start, Restart and Stop Container                                                                                                                                        |
| Linux                    | Start, Restart and Stop Service                                                                                                                                          |
| Windows                  | Run Command (PowerShell remoting)                                                                                                                                        |
| File Transfer            | SFTP, SCP, FTP/FTPS, SMB and WinRM Copy To                                                                                                                               |
| Tales ERP                | Create Task, Create Vulnerability Task                                                                                                                                   |

Notes on the job form:

* Fields marked as sensitive (tokens, passwords) show as ten asterisks after saving. Leaving the asterisks unchanged keeps the stored value.
* Defaults you set in Action Center Settings prefill the form when you add a new job node. Opening an existing job never overwrites its values.
* The asset types offered depend on the job. For example, Microsoft Teams offers only device and user, and Slack **Create Channel** only user.
* File jobs that read a local file accept only paths inside the media directory (or locations an administrator added). Windows copy jobs need an absolute directory such as `C:\reports` and a plain file name.

### What's next?

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Sample Workflow</strong></td><td>Build a Post Discovery workflow that reports devices missing EDR to Slack.</td><td></td></tr><tr><td><strong>Action Center Settings</strong></td><td>Store default credentials for each integration.</td><td></td></tr><tr><td><strong>About Action Center</strong></td><td>How Action Center fits into the platform.</td><td></td></tr><tr><td><strong>Query Reference</strong></td><td>Write the AQL queries that conditions use.</td><td></td></tr></tbody></table>
