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

# Data Transformers

> Clean and reshape caller data before your agent speaks or triggers actions.

Data Transformers let you run deterministic text logic on any value your agent pulls in from variables, actions, or flows—no custom code required. Use them to normalise CRM fields, branch on boolean checks, or clean up API payloads before the LLM ever sees the data.

## When to use Data Transformers

* Format external data (e.g. strip symbols from phone numbers or rewrite salutations) before you reference it inside prompts.
* Enforce guard rails by comparing values or routing between true/false outputs.
* Share the same transformation across multiple agents, pre-call actions, or flow nodes and keep everything in sync.

## Open the workspace view

<Steps>
  <Step>In the left navigation choose **Build → Data Transformers**.</Step>
  <Step>Select the workspace you want to manage (you must use a non-system workspace ID).</Step>
  <Step>Use the search bar to filter by name or description, or page through the list if you have many definitions.</Step>
</Steps>

## Create or edit a transformer

1. Click **New Transformer** (or use the menu beside an existing item and choose **Edit**).
2. Provide a **Name** and optional **Description** so team-members understand what the transformer does.
3. Build the **Expression Pipeline**:
   * Each block (e.g. `expr1`, `expr2`) represents one transformation step.
   * Choose the **Transformation** type and select the **Input** source:
     * `Original Input` runs against whatever text you paste into the top *Input* field.
     * Any `expr#` feed lets you chain from a previous block’s output.
   * Fill out the parameters that appear for the selected type (see the table below).
   * Add more blocks with **Add expression** or remove a block with the ✕ icon (except the first one).
4. Click **Evaluate** to run the full chain against the sample input. The drawer shows intermediate outputs for each block plus the final output so you can verify the logic.
5. Press **Save**. Your transformer is instantly available anywhere variables are inserted.

### Supported expression types

| Transformation       | Typical use cases                                                                                                                                                                                               | Key parameters                                                                                                                                                                                                                      |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Find & Replace**   | Swap keywords, scrub PII, convert newlines to HTML, etc.                                                                                                                                                        | `searchValue`, `replaceValue`, `caseSensitive`, optional regex flags.                                                                                                                                                               |
| **Substring**        | Extract a specific part of the text for enhanced text processing.                                                                                                                                               | `startIndex`, `endIndex` (or `length`).                                                                                                                                                                                             |
| **Regex Extract**    | Pull a matching portion of text using a regular expression. Useful for extracting dates, IDs, emails, or any structured fragment from free-form input. Returns an empty string when the pattern does not match. | `pattern` (required), optional `flags` (`i` for case-insensitive, `m` for multiline), `matchIndex` (`0` = first match, `1, 2…` = nth match, `-1` = last match), `groupIndex` (`0` = whole match, `1, 2…` = numbered capture group). |
| **Compare**          | Turn comparisons into explicit `true`/`false` answers (e.g. numeric thresholds, matching strings).                                                                                                              | `comparisonOperator` (`==`, `!=`, `<`, `>`, `<=`, `>=`), `rightOperand`, `caseSensitive`.                                                                                                                                           |
| **Conditions**       | Combine two boolean inputs with `AND` or `OR`. Ideal for pre-call/action gating.                                                                                                                                | `logicalOperator` and a secondary input (`expr#`) to compare.                                                                                                                                                                       |
| **Ternary Operator** | Return a custom message depending on whether the incoming value is truthy/falsy.                                                                                                                                | `trueOutput`, `falseOutput`.                                                                                                                                                                                                        |

You can mix and match types inside the same pipeline. Every block outputs plain text, so downstream steps (and the agent) can read the result immediately.

### Tips for complex pipelines

* Use descriptive descriptions so future editors understand why a pipeline exists.
* When chaining expressions, double-check the **Input** selector; `expr2` defaults to the previous block, but you can point it at any earlier result.
* Evaluating often helps you catch whitespace or case-sensitivity issues before anyone attaches the transformer to production prompts.

## Apply a transformer to variables

Wherever the variable popover appears (Guidelines, Initial Message, flows, etc.), you can apply a transformer in-line:

1. Type `{{` to open the variable popper and select a variable as usual.
2. Enable **Apply data transformation** at the bottom of the popper.
3. Pick the transformer by name — the popper auto-completes transformer names and shows a preview of the expression chain so you can verify the pipeline before inserting. The inserted snippet renders as `[TransformerName({{variableName}})]`, and the stored value includes the transformer ID so the backend can execute the pipeline automatically.

This works for system, interaction, and custom variables. On execution the platform pushes the transformed value into the agent prompt, HTTP request body, or wherever the variable lives.

## Manage safely

* **Usage-aware deletion** – clicking **Delete** runs a usage check first. If the transformer is referenced by any agent, action, or flow node you will see a detailed report and deletion is blocked until you remove those references.
* **Workspace-wide search** – the list view fetches every transformer in the workspace so you can filter locally without pagination round trips.
* **Exports & clones** – AI Agent exports/imports and duplicates automatically carry along any referenced transformers and rebuild usage links in the target workspace.

## Related pages

<Columns cols={2}>
  <Card title="AI Agents" icon="robot" href="/build/ai-agents">Inject transformed values into greetings, guidelines, and agent settings.</Card>
  <Card title="Pre-Call Actions" icon="bolt" href="/build/ai-agents/pre-call-actions">Combine transformers with API responses before a call starts.</Card>
</Columns>
