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

# Extracted Variables

> AI, toolpath, and DTMF extraction in flow agents

Extracted variables are **flow-agent only**. They are created by nodes during execution from user input, tool responses, or DTMF and are available to successor nodes.

## Types of Extraction

### 1. AI Extracted Variables (Conversation Nodes)

AI extraction uses LLM function calling to pull structured data from the conversation using natural language instructions.

**Configuration:**

* **Extraction Method**: `llm_function_calling`
* **Extraction Prompt**: Natural language description of what to extract
* **Data Type**: string, number, boolean, array, or object
* **Required**: Whether the node depends on this extraction succeeding

**Example:**

```
Variable: customer_name
Extraction Prompt: "Extract the customer's full name from their response"
Data Type: string
Required: true
```

**Supported Data Types:** string, number, boolean, array, object

**Advanced:** Enum values, nested objects, array item types

### 2. Toolpath Extracted Variables (Tool & Web Tool Nodes)

Toolpath extraction uses JSONPath to pull values from tool response data.

**Configuration:**

* **User format**: `$.path.to.value` (JSONPath)
* **Backend format**: `result.path.to.value` (converted automatically)
* **Validation**: Against actual (API) or expected (Web) response
* **Response format**: JSON object or plain string

**JSONPath examples:**

```
$.data.user.email          → Nested field
$.items[0].name            → First item
$.results[*].id            → All IDs
$.data.prices[?(@.active)] → Filter
$                          → Entire response (for string)
```

**Response formats:**

1. **Object (JSON):** Use paths like `$.data.user`, `$.data.items[0]`
2. **String:** Use `$` to get the full string

#### API Tool Nodes

1. Click **Test Tool** to run with real data
2. Use the **path selector** on the actual response
3. Browse the tree, click a field to set the JSONPath
4. Check the preview and save

#### Web Tool Nodes

Web tools run in the browser and can’t be tested server-side:

1. **Define expected response**: Paste JSON object or string
2. Open the **path selector** and use that structure
3. Click fields to set paths and preview
4. Manually test the web tool to confirm the real response matches

**Example expected response (object):**

```json theme={null}
{
  "cart": {
    "total": 149.99,
    "items": [{"name": "Product A", "price": 49.99}],
    "item_count": 2
  }
}
```

Or as string: `"Successfully added 2 items to cart. Total: $149.99"`

**Best practices:**

* **API**: Test first, then configure extraction; test success and error shapes
* **Web**: Define a realistic expected structure; document object vs string; test manually

### 3. DTMF Captured Variables (Conversation & Start Nodes)

DTMF capture creates a variable from keypad input (0-9, \*, #).

**Configuration:**

* **Enable DTMF Capture**: Toggle in node settings
* **Variable Name**: Name for the captured value
* **Sync**: Automatically added to extracted variables

**Characteristics:** Always string; when enabled, number-key DTMF transitions are disabled for that node.

**Example:**

```
Variable: account_number
DTMF Capture: Enabled
Description: "DTMF captured input"
```

## Extraction Availability

Extracted variables are available only to **successor nodes**:

* ✅ Nodes that run after the node that created the variable
* ❌ Nodes that run before or in parallel
* ❌ Global nodes (`isGlobal: true`)

See [Availability & Context](./availability-and-context) for full rules and [Advanced Features](./advanced) for the path selector and nested/array types.
