> ## Documentation Index
> Fetch the complete documentation index at: https://help.statisfy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Building Your First Automation

> Step-by-step guide to creating your first automation in Agent Studio

# Building Your First Automation

This guide walks you through creating a simple automation that sends a Slack notification when an account's health score changes.

## Prerequisites

* Access to Agent Studio in your Statisfy account
* Slack integration configured (for notifications)
* At least one account segment defined

## Step 1: Create a New Automation

1. Navigate to **Agent Studio** from the main navigation
2. Open one of your folders (or **My Collection**) and click **New Flow**
3. In the **Start With A Template** window, scroll to the **Start from scratch** section at the bottom and click **Blank Flow**

You'll see the visual canvas with the component panel on the left.

<Note>
  The **New Flow** button appears when you're inside a regular folder or My Collection—it isn't shown in the All Flows view or the Legacy Workflows folder.
</Note>

### Starting from a template instead

The **Start With A Template** window also offers ready-made automations you can use as a starting point. Browse by category in the sidebar, or use the search box to find a template, then select a template card to create a copy you can customize. This is the fastest way to get going if a template already matches your use case.

## Step 2: Add a Trigger

Every automation starts with a trigger. For this example, we'll trigger when an account enters a segment.

1. From the **Triggers** section in the component panel, drag **Account Segment V2** onto the canvas
2. Click on the node to configure it
3. Select your target segment (e.g., "At Risk Accounts")

<Tip>
  The Account Segment trigger fires when an account enters the segment, exits the segment, or both—depending on the **Trigger On** setting you configure. By default, it triggers on entry only. To trigger on exit or both enter and exit events, adjust the **Trigger On** option in the trigger configuration.
</Tip>

The trigger node will output:

* `account_id` - The ID of the affected account
* `account_data` - Full account information including name, owner, custom fields, etc.

## Step 3: Add an Action

Now let's add a Slack notification action.

1. From the **Actions** section, drag **Slack V2** onto the canvas
2. **Connect** the trigger to the action by dragging from the trigger's output handle to the Slack node's input handle
3. Click on the Slack node to configure it:

**Configuration:**

* **Channel**: Select your target Slack channel (e.g., #customer-alerts)
* **Message**: Use @ notation to include dynamic data:

```
:warning: Account Alert

*@account_data.name* has entered the At Risk segment

- Health Score: @account_data.health_score
- Owner: @account_data.owner_name
- ARR: $@account_data.arr

Please review and take action.
```

## Step 4: Test the Node

Before activating the full flow, test the Slack node individually:

1. Click on the Slack node to select it
2. Click the **Play** button (▶) on the node
3. You'll be prompted to provide test input data
4. Enter sample data or select an existing account
5. Click **Run**

Check your Slack channel to verify the message was sent correctly.

## Step 5: Add Conditional Logic (Optional)

Let's enhance the automation to only alert for high-value accounts:

1. From **Logic**, drag **Condition V2** between the trigger and Slack node
2. Delete the direct connection from trigger to Slack
3. Connect: Trigger → Condition → Slack (true output)
4. Configure the Condition node:
   * **Field**: `@account_data.arr`
   * **Operator**: `greater than`
   * **Value**: `100000`

Now the Slack notification only sends for accounts with ARR > \$100,000.

<Note>
  The **False** output of the Condition node can be connected to a different action, or left unconnected to take no action for non-matching accounts.
</Note>

## Step 6: Save and Activate

1. Click **Save** to save your automation
2. Give it a descriptive name (e.g., "High-Value At Risk Alert")
3. Toggle the **Active** switch to enable the automation

Your automation is now live and will trigger whenever a high-value account enters the At Risk segment.

## Complete Flow

Here's what your completed automation looks like:

```
┌─────────────────┐     ┌─────────────┐     ┌─────────────┐
│ Account Segment │────▶│  Condition  │────▶│    Slack    │
│   (At Risk)     │     │ (ARR>100K)  │     │   Message   │
└─────────────────┘     └─────────────┘     └─────────────┘
                              │
                              ▼ (False)
                         (No action)
```

## Monitoring Your Automation

After activation, you can monitor your automation:

* **Run History**: View past executions and their status
* **Logs**: See detailed execution logs for debugging
* **Metrics**: Track how often the automation triggers and succeeds

## Publishing Your Own Templates

Once you've built an automation your team will want to reuse, you can publish it as a template so it appears in the **Start With A Template** window for everyone in your workspace.

1. Move or build the automation inside the **Templates** folder
2. Open the flow and click **Save as Template** in the toolbar (this changes to **Update Template** if the template has already been published)
3. In the publish dialog, pick a category—or type a new one in the **Enter new category** field
4. Click **Publish Template**

You'll see a "Template published successfully" confirmation, and the template becomes available to your team.

<Tip>
  To manage existing templates, open the **Templates** folder and click **Modify Templates** (this replaces the **New Flow** button there). From the Modify Templates window you can open a template card to edit the flow, or delete templates you no longer need.
</Tip>

## Troubleshooting

<Accordion title="Automation not triggering">
  * Verify the trigger segment criteria are correct
  * Check that accounts are actually entering/exiting the segment
  * Ensure the automation is set to **Active**
</Accordion>

<Accordion title="Slack message not sending">
  * Verify Slack integration is properly configured
  * Check that the channel exists and the bot has access
  * Test the node individually with the play button
</Accordion>

<Accordion title="Data not appearing in message">
  * Verify @ notation syntax is correct
  * Check that the field exists in the account data
  * Use the test feature to inspect available data
</Accordion>

## Next Steps

<CardGroup cols={2}>
  <Card title="Explore All Triggers" icon="bolt" href="/agent-studio/automations/triggers">
    Learn about different trigger types
  </Card>

  <Card title="Processing Components" icon="gears" href="/agent-studio/automations/processing">
    Transform and manipulate data
  </Card>

  <Card title="Action Components" icon="paper-plane" href="/agent-studio/automations/actions">
    Send notifications and update records
  </Card>

  <Card title="Testing Flows" icon="vial" href="/agent-studio/automations/testing">
    Best practices for testing automations
  </Card>
</CardGroup>
