> ## 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.

# Processing Components

> Reference guide for data transformation and manipulation components

# Processing Components

Processing components transform, combine, and manipulate data as it flows through your automation. Use them to prepare data for conditions, format content for actions, or extract specific values.

## Data Object Fundamentals

All data in Agent Studio flows as **Data objects** - structured key-value containers:

```json theme={null}
{
  "account_name": "Acme Corp",
  "health_score": 75,
  "contacts": [
    { "name": "John", "role": "Champion" },
    { "name": "Jane", "role": "Executive Sponsor" }
  ]
}
```

Processing components modify these objects—adding fields, filtering keys, combining multiple objects, or extracting specific values.

***

## Create Data V2

Creates a new Data object with specified key-value pairs.

### When to Use

* Initialize data at the start of a flow
* Create structured data from multiple sources
* Build payloads for API calls or actions

### Configuration

| Field                | Description                     |
| -------------------- | ------------------------------- |
| **Number of Fields** | How many key-value pairs (1-15) |
| **Field 1 Key**      | Name of the first field         |
| **Field 1 Value**    | Value (supports @ notation)     |
| ...                  | Additional fields as configured |

### Example: Build Email Context

**Configuration:**

```
Field 1 Key: recipient_name
Field 1 Value: @account_data.owner_name

Field 2 Key: account_name
Field 2 Value: @account_data.name

Field 3 Key: health_score
Field 3 Value: @account_data.health_score

Field 4 Key: alert_type
Field 4 Value: health_drop
```

**Output:**

```json theme={null}
{
  "recipient_name": "Jane Smith",
  "account_name": "Acme Corp",
  "health_score": 65,
  "alert_type": "health_drop"
}
```

***

## Update Data V2

Adds or updates fields in an existing Data object.

### When to Use

* Add computed fields to existing data
* Append metadata or timestamps
* Modify values for downstream processing

### Configuration

| Field                | Description                     |
| -------------------- | ------------------------------- |
| **Number of Fields** | How many fields to add/update   |
| **Field N Key**      | Field name to add or update     |
| **Field N Value**    | New value (supports @ notation) |

### Example: Add Timestamp and Flag

**Input:**

```json theme={null}
{
  "account_name": "Acme Corp",
  "health_score": 65
}
```

**Configuration:**

```
Field 1 Key: processed_at
Field 1 Value: (current timestamp)

Field 2 Key: requires_attention
Field 2 Value: true
```

**Output:**

```json theme={null}
{
  "account_name": "Acme Corp",
  "health_score": 65,
  "processed_at": "2024-02-20T10:30:00Z",
  "requires_attention": true
}
```

***

## Filter Data V2

Creates a new Data object containing only specified keys.

### When to Use

* Remove sensitive fields before logging
* Reduce data size for downstream processing
* Extract specific fields from complex objects

### Configuration

| Field    | Description                          |
| -------- | ------------------------------------ |
| **Keys** | Comma-separated list of keys to keep |

### Example: Keep Only Essential Fields

**Input:**

```json theme={null}
{
  "account_id": "acc_123",
  "account_name": "Acme Corp",
  "owner_email": "jane@company.com",
  "internal_notes": "Sensitive info...",
  "api_key": "secret..."
}
```

**Configuration:**

```
Keys: account_id, account_name, owner_email
```

**Output:**

```json theme={null}
{
  "account_id": "acc_123",
  "account_name": "Acme Corp",
  "owner_email": "jane@company.com"
}
```

***

## Extract Key V2

Extracts a single value from a Data object.

### When to Use

* Get a specific field for a condition
* Extract a value to use as a standalone input
* Access nested values

### Configuration

| Field   | Description                                                  |
| ------- | ------------------------------------------------------------ |
| **Key** | The key to extract (supports dot notation for nested values) |

### Example: Extract Nested Value

**Input:**

```json theme={null}
{
  "account": {
    "name": "Acme Corp",
    "primary_contact": {
      "email": "john@acme.com"
    }
  }
}
```

**Configuration:**

```
Key: account.primary_contact.email
```

**Output:**

```json theme={null}
{
  "value": "john@acme.com"
}
```

***

## Combine Data V2

Merges multiple Data objects into one.

### When to Use

* Combine data from multiple sources
* Merge results from parallel paths
* Aggregate data for reporting

### Configuration

| Field         | Description                                         |
| ------------- | --------------------------------------------------- |
| **Operation** | How to combine: Concatenate, Append, Merge, or Join |
| **Inputs**    | Connect multiple data inputs                        |

### Operations Explained

#### Concatenate

Combines arrays of Data objects into a single array.

```
Input 1: [{ "a": 1 }, { "a": 2 }]
Input 2: [{ "a": 3 }]
Output:  [{ "a": 1 }, { "a": 2 }, { "a": 3 }]
```

#### Append

Adds new Data objects to an existing array.

```
Input 1: [{ "a": 1 }]
Input 2: { "a": 2 }
Output:  [{ "a": 1 }, { "a": 2 }]
```

#### Merge

Combines fields from multiple objects into one (later values override earlier).

```
Input 1: { "a": 1, "b": 2 }
Input 2: { "b": 3, "c": 4 }
Output:  { "a": 1, "b": 3, "c": 4 }
```

#### Join

Combines objects based on a common key.

```
Input 1: { "id": 1, "name": "Acme" }
Input 2: { "id": 1, "score": 75 }
Join Key: id
Output:  { "id": 1, "name": "Acme", "score": 75 }
```

***

## Select Data V2

Selects a single item from a list of Data objects by index.

### When to Use

* Get the first or last item from a list
* Access a specific item by position
* Extract one result from a query

### Configuration

| Field     | Description                                                  |
| --------- | ------------------------------------------------------------ |
| **Index** | Position to select (0-based, negative values count from end) |

### Example: Get First Account

**Input:**

```json theme={null}
[
  { "name": "Acme Corp", "score": 75 },
  { "name": "Beta Inc", "score": 82 },
  { "name": "Gamma LLC", "score": 60 }
]
```

**Configuration:**

```
Index: 0
```

**Output:**

```json theme={null}
{ "name": "Acme Corp", "score": 75 }
```

### Example: Get Last Item

**Configuration:**

```
Index: -1
```

**Output:**

```json theme={null}
{ "name": "Gamma LLC", "score": 60 }
```

***

## Calculate Expression V2

Evaluates mathematical expressions on data fields.

### When to Use

* Compute percentages or ratios
* Perform arithmetic operations
* Calculate derived metrics

### Configuration

| Field          | Description                                              |
| -------------- | -------------------------------------------------------- |
| **Expression** | Mathematical expression (supports @ notation for values) |
| **Output Key** | Name for the result field                                |

### Supported Operations

| Operation      | Syntax | Example              |
| -------------- | ------ | -------------------- |
| Addition       | `+`    | `@a + @b`            |
| Subtraction    | `-`    | `@total - @discount` |
| Multiplication | `*`    | `@price * @quantity` |
| Division       | `/`    | `@score / 100`       |
| Modulo         | `%`    | `@value % 10`        |
| Parentheses    | `()`   | `(@a + @b) * @c`     |

### Example: Calculate Percentage

**Input:**

```json theme={null}
{
  "current_score": 75,
  "max_score": 100
}
```

**Configuration:**

```
Expression: (@current_score / @max_score) * 100
Output Key: percentage
```

**Output:**

```json theme={null}
{
  "current_score": 75,
  "max_score": 100,
  "percentage": 75
}
```

***

## Current Date V2

Returns the current date and time in a selected timezone.

### When to Use

* Get the current timestamp for data enrichment
* Compare dates in conditions
* Add timestamps to records or messages

### Configuration

| Field        | Description                                                          |
| ------------ | -------------------------------------------------------------------- |
| **Timezone** | Select the timezone (default: UTC). Supports all standard timezones. |

### Output Data

```json theme={null}
{
  "success": true,
  "timezone": "America/New_York",
  "datetime": "2024-02-20 10:30:00 EST",
  "date": "2024-02-20",
  "time": "10:30:00"
}
```

***

## Date Formatter V2

Automatically formats all date fields found in a Data object to a specified format.

### When to Use

* Standardize date formats before sending emails or Slack messages
* Convert ISO dates to human-readable formats
* Prepare data for external API calls that require specific date formats

### Configuration

| Field           | Description                                                       |
| --------------- | ----------------------------------------------------------------- |
| **Date Format** | Target format for all date fields (e.g., `%Y-%m-%d`, `%B %d, %Y`) |

### How It Works

The component recursively scans all fields in the input Data object (including nested objects), detects ISO date strings, and reformats them to the specified format.

### Example

**Input:**

```json theme={null}
{
  "account_name": "Acme Corp",
  "renewal_date": "2024-06-15T00:00:00Z",
  "last_activity": "2024-02-20T14:30:00Z"
}
```

**Configuration:**

```
Date Format: %B %d, %Y
```

**Output:**

```json theme={null}
{
  "account_name": "Acme Corp",
  "renewal_date": "June 15, 2024",
  "last_activity": "February 20, 2024"
}
```

***

## Using @ Notation

The `@` symbol references values from incoming data:

| Syntax          | Description        | Example Result                 |
| --------------- | ------------------ | ------------------------------ |
| `@field`        | Top-level field    | `@name` → "Acme"               |
| `@field.nested` | Nested field       | `@account.owner.name` → "Jane" |
| `@field[0]`     | Array index        | `@contacts[0]` → First contact |
| `@`             | Entire data object | Full incoming data             |

### Dynamic Field References

You can build field references dynamically:

```
Field Key: alert_@account_data.priority_level
```

If `priority_level` is "high", creates field `alert_high`.

***

## Common Patterns

### Pattern: Data Enrichment Pipeline

```
Trigger → Create Base Data → Add Metadata → Add Computed Fields → Action
```

### Pattern: Data Filtering Before Action

```
Trigger → Filter Sensitive Fields → Send to External API
```

### Pattern: Aggregate Multiple Sources

```
┌─ SQL Query 1 ─┐
               ├──▶ Combine Data ──▶ Process
└─ SQL Query 2 ─┘
```

### Pattern: Extract and Validate

```
Trigger → Extract Key → Condition (not empty) → Action
```

***

## Fetch Object Data V2

Fetches the latest data for an entity from the database, returning a fresh Data object. This is useful when earlier components in the flow may have modified entity data (e.g., after a Sleep component or Human-in-the-Loop pause) and you need the most current values.

### When to Use

* After a **Sleep V2** component, to get updated data that may have changed during the wait
* After a **Human-in-the-Loop** pause, to pick up any manual changes
* When you need to re-read entity data that another automation may have modified
* To ensure downstream components work with the latest field values

### Configuration

| Field           | Description                                                       |
| --------------- | ----------------------------------------------------------------- |
| **Entity Type** | The type of entity to fetch (Account, Contact, Opportunity, etc.) |
| **Entity ID**   | The ID of the entity to fetch (supports @ notation)               |

### Output Data

Returns a Data object with all current fields for the entity, identical in structure to what the trigger segment provides.

### Example: Refresh After Sleep

```
Trigger (Account) ──→ Sleep (24 hours) ──→ Fetch Object Data ──→ Check Health Score
                                              │
                                              └─ Returns fresh account data
                                                 including any changes made
                                                 during the 24-hour wait
```

***

## Best Practices

<Accordion title="Build data incrementally">
  Start with Create Data for essential fields, then use Update Data to add more as needed.
</Accordion>

<Accordion title="Filter before external calls">
  Remove sensitive or unnecessary fields before sending data to external systems.
</Accordion>

<Accordion title="Name output keys clearly">
  Use descriptive key names that indicate the data's purpose and origin.
</Accordion>

<Accordion title="Handle missing keys">
  Use conditions to check if required keys exist before processing them.
</Accordion>

## Next Steps

<CardGroup cols={2}>
  <Card title="Logic Components" icon="code-branch" href="/agent-studio/automations/logic">
    Add conditional routing
  </Card>

  <Card title="Action Components" icon="paper-plane" href="/agent-studio/automations/actions">
    Use processed data in actions
  </Card>
</CardGroup>
