> 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/sample-workflow.md).

# Sample Workflow

Build a workflow that runs after every discovery, finds devices that no EDR adapter has reported, and posts the list to Slack.

In this tutorial you build a workflow that runs after each completed discovery, checks how many servers are missing your EDR product, and sends the list to a Slack channel. You then test it with a manual run and read the result in the run history.

The example assumes your EDR is CrowdStrike Falcon (adapter slug `falcon-crowdstrike`). Replace the adapter slug in the query with the one your EDR uses.

### Before you begin

* Required permissions: `workflows.add_workflow`, `workflows.change_workflow` and `workflows.run_workflow`.
* At least one completed discovery.
* A Slack incoming webhook URL for the channel that should receive the message. Create it in your Slack workspace as an incoming webhook.
* Optionally, store the webhook URL once as a default for the Slack **Send Notification** job in Action Center Settings. If you skip this, you enter it in the job in step 5.
* A saved query that finds the devices you care about. Step 1 creates one.

### Steps

{% stepper %}
{% step %}

#### Save the query

Open the device query page, enter the query below, and save it with a name such as `Servers without EDR`. See Create and Save Queries.

```
Category = Server AND NOT Adapters = falcon-crowdstrike
```

`Adapters` lists the adapters that reported each device, so `NOT Adapters = falcon-crowdstrike` matches devices CrowdStrike did not report. The syntax is explained in the Query Reference.
{% endstep %}

{% step %}

#### Create the workflow

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

{% step %}

#### Set the Post Discovery trigger

On the **Triggers** node, choose **Event Based**, then choose **Post Discovery** in the second drop-down. The workflow now starts every time a discovery finishes successfully.
{% endstep %}

{% step %}

#### Add a condition

Select **Add Condition Node** in the toolbar and open the new node. Set:

| Field        | Value                 |
| ------------ | --------------------- |
| Inventory    | Devices               |
| Query        | `Servers without EDR` |
| **Function** | `count`               |
| **Operand**  | Greater Than          |
| **Value**    | `0`                   |

Select **Save**, then drag an arrow from the **Triggers** node to the condition node.
{% endstep %}

{% step %}

#### Add the Slack job

Select **Add Job Node**, type `Slack` in **Search jobs...** and choose **Send Notification** under Slack. In the **Edit Send Notification Integration** form:

* Keep **Device** selected as the asset type.
* Paste your webhook URL into **Hook URL** (skip this if the default from Action Center Settings is already filled in).

Select **Save**. Then drag an arrow from the condition node to the Slack node. When the **Select Edge Status** dialog opens, choose **SUCCESS**. The message is sent only when at least one server lacks the EDR.
{% endstep %}

{% step %}

#### Choose the columns to report

Select **Edit Columns**, open the device list, and add the columns you want in the message, for example `Hostname` and `IpAddresses`. The Slack job formats up to four columns as a table. With more columns it writes one line per column for each device.
{% endstep %}

{% step %}

#### Save and check it is active

Select **Save**. In the **Basic Info** dialog, enter a **Title** such as `Servers without EDR` and a **Description** that explains the alert, then select **Create**. Both are required and both appear in the Slack message: the title as the heading and the description as the first line of text.

Back on the **Action Center** list, check that **Active Status** is on and that **Trigger** shows `post_discovery`.
{% endstep %}

{% step %}

#### Test with a manual run

In the workflow's row, select the play button. The console shows "Workflow Servers without EDR has been run". A manual run uses the latest completed discovery, so you do not have to wait for the next one.
{% endstep %}
{% endstepper %}

### Verify the result

1. Check the Slack channel. The message has the workflow title as its heading, the description, and a block such as `device count: 12` followed by your columns.
2. Open the run history in Action Center. The new run shows **Status** success and **Triggered By** with your user name. Open it and read **Audit Logs**: you should see the condition result, "The success edges on the condition are started." and "Workflow finished."
3. After the next discovery completes, a second run appears with **Triggered By** `system`.

If the count is zero, the condition is false and no message is sent. The audit log then says "The failed edges on the condition are started." This is expected when every server has the EDR.

### Variation: open a Jira issue instead

To track the finding in Jira, add a **Create Issue/Ticket on Jira Cloud** job after the Slack job (or instead of it) and connect it with an arrow. It creates one issue titled with the workflow title, with the device table in its description. Fill in these fields:

| Field               | Value                                                            |
| ------------------- | ---------------------------------------------------------------- |
| URL                 | Your Jira site, for example `https://your-company.atlassian.net` |
| Email               | The Atlassian account that owns the token                        |
| API Token           | Your Jira API token                                              |
| Project Key         | The project key, for example `KAN`                               |
| Issue Type          | JSON, default `{"name": "Task"}`; must exist in the project      |
| Account Assignee ID | Optional account ID of the assignee                              |

Use **Create Issue/Ticket Per Asset on Jira Cloud** if you want one issue per device; its summary is the hostname.

### Troubleshooting

| Symptom                                                                    | Cause                                                                         | Fix                                                                                              |
| -------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| Nothing arrives in Slack                                                   | The condition was false, or the webhook URL is wrong.                         | Read the run's **Audit Logs**. If the condition is true, test the webhook URL with another tool. |
| The Slack message shows `count: 0` and no rows                             | The Slack job is connected to the **Triggers** node instead of the condition. | Connect the trigger to the condition and the condition to the job with a `SUCCESS` arrow.        |
| "Error occurred on creating workflow. Please check nodes marked with red." | A node is missing a required field.                                           | Open the marked node, fill in the required fields and save again.                                |
| The workflow does not run after discovery                                  | **Active Status** is off, or the trigger is not **Post Discovery**.           | Turn on **Active Status** and check the **Trigger** column.                                      |
| The run log says "No discovery found."                                     | No discovery has completed yet.                                               | Run a discovery, then run the workflow again.                                                    |

### 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>Rules and Triggers</strong></td><td>All trigger types, conditions, compare jobs and job options.</td><td></td></tr><tr><td><strong>Action Center Settings</strong></td><td>Store default credentials for jobs.</td><td></td></tr><tr><td><strong>Query Reference</strong></td><td>Write your own device queries.</td><td></td></tr></tbody></table>
