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

# Variables

> Learn how to use variables to personalize your agent's prompts dynamically.

Variables allow you to **inject dynamic data directly into your agent's prompt**, like the customer's name, phone number, current date, or any custom data you define. This lets your agent personalize conversations and access relevant information without hardcoding it into the prompt.

## Quick Start

<Steps>
  <Step title="Reference a variable in your prompt">
    Use double curly braces: `{{variableName}}`
  </Step>

  <Step title="System defaults work automatically">
    Variables like `{{firstName}}`, `{{currentDate}}`, and `{{phoneNumber}}` are always available
  </Step>

  <Step title="Create custom variables for your data">
    Add custom properties to contacts (e.g., `{{contractId}}`, `{{city}}`) and reference them in your prompt
  </Step>
</Steps>

***

<Tabs>
  <Tab title="Use Cases">
    * **Personalize greetings:** *"Hi `{{firstName}}`, this is Emma from Telli"*
    * **Reference customer data:** *"I see you're calling about contract `{{contractId}}`"*
    * **Context-aware routing:** Use customer properties to guide the conversation flow
    * **Time-based behavior:** Adjust responses based on `{{currentTime}}` or `{{currentWeekday}}`
    * **Pass order details:** Include order numbers, product names, or any custom data from your system
  </Tab>

  <Tab title="Variable Types">
    These are standard variables that telli provides automatically for every call. You don't need to configure them, they're always available:

    | **Variable**             | **Description**                         |
    | :----------------------- | :-------------------------------------- |
    | **`{{firstName}}`**      | Customer's first name                   |
    | **`{{lastName}}`**       | Customer's last name                    |
    | **`{{phoneNumber}}`**    | Customer's phone number                 |
    | **`{{email}}`**          | Customer's email address                |
    | **`{{language}}`**       | Customer's language                     |
    | **`{{currentDate}}`**    | Today's date                            |
    | **`{{currentTime}}`**    | Current time                            |
    | **`{{currentWeekday}}`** | Current day of the week                 |
    | **`{{callDirection}}`**  | Whether the call is inbound or outbound |
  </Tab>

  <Tab title="Custom Variables">
    Variables and properties you define yourself when creating contacts in telli. These give you complete flexibility to pass any information to any agent in the account.

    <video loop muted playsInline style={{ width: '100%', cursor: 'pointer' }} onMouseEnter={(e) => e.currentTarget.play()} onMouseLeave={(e) => { e.currentTarget.pause(); e.currentTarget.currentTime = 0; }}>
      <source src="https://mintcdn.com/telli/yTwqc2QbhCfx6_2_/onboarding-media/Cookbooks/Variables/CB_Variables_CreateCustom.mp4?fit=max&auto=format&n=yTwqc2QbhCfx6_2_&q=85&s=fb2ebbe3cb8dee1634efc0530b43282e" type="video/mp4" data-path="onboarding-media/Cookbooks/Variables/CB_Variables_CreateCustom.mp4" />
    </video>

    | **Variable**                    | **Example Use Case**              |
    | :------------------------------ | :-------------------------------- |
    | **`{{product}}`**               | Customer's current product        |
    | **`{{city}}`**                  | Customer's city                   |
    | **`{{customerId}}`**            | Customer ID                       |
    | **`{{contractId}}`**            | Contract number                   |
    | **`{{currentTotalPrice}}`**     | Current contract value            |
    | **`{{__contact_empfangsart}}`** | Custom field from contact details |

    <Warning>
      The variable names you use in the prompt must exactly match the names you define in your contact details. If you name a field **`contractId`** in the contact, you must reference it as **`{{contractId}}`** in the prompt, not **`{{contract_id}}`** or **`{{ContractId}}`**.
    </Warning>
  </Tab>
</Tabs>

***

<Tabs>
  <Tab title="Best Practices">
    <video loop muted playsInline style={{ width: '100%', cursor: 'pointer' }} onMouseEnter={(e) => e.currentTarget.play()} onMouseLeave={(e) => { e.currentTarget.pause(); e.currentTarget.currentTime = 0; }}>
      <source src="https://mintcdn.com/telli/yTwqc2QbhCfx6_2_/onboarding-media/Cookbooks/Variables/CB_Variables_Insert.mp4?fit=max&auto=format&n=yTwqc2QbhCfx6_2_&q=85&s=8068a8d57207896832f89a26a4d621cc" type="video/mp4" data-path="onboarding-media/Cookbooks/Variables/CB_Variables_Insert.mp4" />
    </video>

    **Define Variables in a Centralized Section**

    **Define all variables in a centralized section** so the agent has full clarity on what values are available.

    ***

    **Don't Build Logic Around Raw Values**

    If a variable is unknown, empty, or **`0`**, the agent has no instruction on how to interpret it and may not know which path to follow.

    Instead, clearly **define what each variable represents in natural language** and explicitly instruct the agent what to do in each scenario.

    <Warning>
      ### What not to do

      ```
      Before proceeding, review the available customer data and choose the path:

      {{letter_received}} == "Yes" and {{rsv_present}} == "Yes" → Path 6.2
      {{letter_received}} == "Yes" and {{rsv_present}} == "No" → Path 6.3
      ```

      What the agent sees if there is no letter and no RSV:

      `0 == "Yes" and 0 == "Yes" → Path 6.2`

      The agent sees the raw template syntax and may not know what to do if a value is missing or unexpected.
    </Warning>

    <Check>
      ### What to do

      ```
      # Available customer data

      - Letter received: {{letter_received}}
      - Legal protection insurance (RSV): {{rsv_present}}

      # Routing rules

      - If the customer has received the letter AND has legal protection insurance → follow Path 6.2
      - If the customer has received the letter but does NOT have legal protection insurance → follow Path 6.3
      - If the letter status is unknown or empty → ask the customer whether they have received a letter before proceeding
      ```

      This way the agent understands the meaning behind each variable and knows exactly what to do in every scenario, including when data is missing.
    </Check>

    ***

    **Reference Variables Where They're Used**

    For longer prompts, define the variable clearly in a centralized section at the top, then reference it again right before it's actually used. This helps reinforce context and reduces the risk of misapplication.

    ***

    **Use Them in Workflows Too**

    The contact properties you set up here also work in workflows. When a workflow runs after a call, you can use the same values to send a webhook, update a contact, or sync to your CRM. You only need to set them up once.

    See [Workflows](/cookbooks/workflows/overview) for the full list of places they can show up.
  </Tab>

  <Tab title="Good to Know">
    * Variable names are **case-sensitive**. `{{contractId}}` is different from `{{ContractId}}`.
    * System default variables are available on every call automatically
    * Custom variables only populate if the contact has that property defined
    * If a variable is undefined, the agent sees an empty value. Make sure to handle missing data in your prompt logic.
    * Variables can be used anywhere in the prompt: in the identity section, conversation script, or rules

    <Tip>
      To avoid confusion, always test your prompt with both populated and empty variable values to ensure the agent handles all scenarios gracefully.
    </Tip>
  </Tab>
</Tabs>
