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

# Variable Referencing

The Rounded Studio supports dynamic content insertion through variable references using `{{variable_name}}`. This feature enables personalized, context-aware conversation flows by embedding variable values where needed.

## Variable Reference Syntax

To reference any variable, wrap its name in double curly braces: `{{variable_name}}`

## Variable Types and Formatting

Variables are automatically formatted according to their defined types, but when inserted into conversation text, **all variables are ultimately rendered as strings**:

<CardGroup cols={2}>
  <Card title="STRING" icon="text">
    Plain text
  </Card>

  <Card title="BOOLEAN" icon="toggle-on">
    True/false (converted to a string like `true` or `false`)
  </Card>

  <Card title="NUMBER" icon="calculator">
    Numeric value (rendered as a string)
  </Card>

  <Card title="DATETIME" icon="calendar">
    Formatted as `Monday, YYYY-MM-DD HH:MM:SS` (returned as a string)
  </Card>

  <Card title="JSON" icon="brackets-curly">
    Complex data structures (serialized to JSON, then inserted as a string)
  </Card>
</CardGroup>

## Variable Scoping

### Global Variables

Global variables are set in the call context and are accessible throughout the entire conversation flow. They can be initialized through:

<CardGroup cols={2}>
  <Card title="API Calls" icon="server">
    Variables initialized through API requests before the call starts
  </Card>

  <Card title="CSV Import" icon="file-csv">
    Variables loaded from CSV files for call campaigns
  </Card>
</CardGroup>

<Tip>
  Global variables are perfect for static context that needs to be available throughout the entire conversation, such as:

  * Customer identification (`customer_id`, `account_number`)
  * Contact information (`phone_number`, `email`)
  * Session data (`call_id`, `timestamp`)
</Tip>

### Task-Specific Variables

Task-specific variables are created within a specific task and may be derived from:

<CardGroup cols={2}>
  <Card title="Extraction" icon="magnifying-glass">
    Capturing user input during the task
  </Card>

  <Card title="API Response Mappings" icon="code">
    Parsing JSON paths after an API call
  </Card>
</CardGroup>

<Warning>
  Task-specific variables:

  * Only become accessible **after** the task in which they are defined completes
  * Cannot be referenced in the same task where they are first defined
  * In a parent-child task structure, child tasks can inherit parent variables, but not vice versa
</Warning>

## Usage Locations

Variables can be referenced in the following places:

<CardGroup cols={3}>
  <Card title="Agent Context" icon="message-bot">
    <div className="mt-2">
      * Initial message
      * Base prompt
      * State-specific prompts
    </div>
  </Card>

  <Card title="Tools" icon="wrench">
    <div className="mt-2">
      * Tool descriptions
      * Parameter descriptions
      * Filler sentences
      * Phone numbers
    </div>
  </Card>

  <Card title="Transitions" icon="arrow-right-arrow-left">
    <div className="mt-2">
      * Task conditions
      * Filler sentences
    </div>
  </Card>
</CardGroup>

<Info>
  **Important Transition Scoping Rules:**

  * **Conditions** can only reference variables that are available before or in the previous (origin) task
  * **Filler Sentences** may include variables that were updated during the current (origin) task
  * Variables must be carefully scoped to avoid undefined variable errors
</Info>

## Best Practices

<AccordionGroup>
  <Accordion icon="route" title="Plan Variable Flow">
    Map out when and how each variable will be introduced and referenced. Always ensure variables are used only after they have been assigned or mapped.
  </Accordion>

  <Accordion icon="list-check" title="Use Correct Types">
    Select the appropriate data type (STRING, BOOLEAN, NUMBER, DATETIME, or JSON) for each variable to ensure proper formatting and behavior.
  </Accordion>

  <Accordion icon="layer-group" title="Follow Scoping Rules">
    Reference variables only after they become available in the conversation flow. Task-specific variables cannot be referenced in the same task where they are defined.
  </Accordion>

  <Accordion icon="spell-check" title="Check Names and Spelling">
    Use consistent, correctly spelled variable names to prevent referencing errors or missing data issues.
  </Accordion>

  <Accordion icon="shield-check" title="Secure Sensitive Data">
    Avoid disclosing private or confidential information in prompts, logs, or transitions.
  </Accordion>

  <Accordion icon="brackets-curly" title="Validate JSON Paths">
    Verify correct JSON path syntax in API response mappings. Ensure any mapped variables are used only in subsequent tasks, after the API call completes.
  </Accordion>
</AccordionGroup>
