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

# Using Context with Bolna Voice AI Agents

> Learn how to effectively use context in Bolna Voice AI agents to create dynamic, personalized, and meaningful interactions

Personalize voice AI conversations by injecting dynamic information into your agent's prompts. Create tailored experiences using customer data, conversation metadata, and custom variables.

***

## Default Variables

The following variables are automatically available in every conversation:

| Variable       | Description                                                 |
| -------------- | ----------------------------------------------------------- |
| `agent_id`     | The `id` of the agent                                       |
| `execution_id` | Unique `id` of the Bolna conversation or call               |
| `call_sid`     | Unique `id` of the phone call (Twilio, Plivo, Vonage, etc.) |
| `from_number`  | Phone number that **initiated** the call                    |
| `to_number`    | Phone number that **received** the call                     |

<Info>
  **Inbound calls:** `from_number` = caller, `to_number` = your agent\
  **Outbound calls:** `from_number` = your agent, `to_number` = recipient
</Info>

### Example: Using Default Variables

<CodeGroup>
  ```php Prompt Template theme={"system"}
  This is your agent Sam. Please have a friendly conversation with the customer.

  Please note:
  The agent has a unique id which is "{agent_id}".
  The call's unique id is "{call_sid}".
  The customer's phone number is "{to_number}".
  ```

  ```php Result (After Substitution) theme={"system"}
  This is your agent Sam. Please have a friendly conversation with the customer.

  Please note:
  The agent has a unique id which is "4a8135ce-94fc-4a80-9a33-140fe1ed8ff5".
  The call's unique id is "PXNEJUFEWUEWHVEWHQFEWJ".
  The customer's phone number is "+19876543210".
  ```
</CodeGroup>

***

## Date, Time & Timezone

<Note>
  By default, conversations include current date and time appended to the system prompt. You can also reference these as variables directly in your prompt for more control over placement and formatting.
</Note>

| Variable       | Description                                                                                   | Example Value               |
| -------------- | --------------------------------------------------------------------------------------------- | --------------------------- |
| `current_date` | Current date in the user's timezone                                                           | `Wednesday, March 18, 2026` |
| `current_time` | Current time in the user's timezone                                                           | `02:30:15 PM`               |
| `timezone`     | Timezone name per [tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) | `Asia/Kolkata`              |

For accurate time, pass the `timezone` via the API when placing calls:

```bash theme={"system"}
curl --request POST \
  --url https://api.bolna.ai/call \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "agent_id": "123e4567-e89b-12d3-a456-426655440000",
  "recipient_phone_number": "+10123456789",
  "user_data": {
    "timezone": "America/New_York"
  }
}'
```

### Example: Using Time Variables in Prompts

<CodeGroup>
  ```php Prompt Template theme={"system"}
  You are a scheduling assistant for {company_name}.
  Today is {current_date} and the current time is {current_time} ({timezone}).

  Only allow bookings during business hours (9 AM - 5 PM).
  ```

  ```php Result (After Substitution) theme={"system"}
  You are a scheduling assistant for Acme Corp.
  Today is Wednesday, March 18, 2026 and the current time is 02:30:15 PM (America/New_York).

  Only allow bookings during business hours (9 AM - 5 PM).
  ```
</CodeGroup>

***

## Custom Variables

Define your own variables by wrapping text in `{}` in your prompt. Pass values via the API when placing calls.

<Tip>
  Any content written between `{}` in the prompt becomes a variable.
</Tip>

### Example: Using Custom Variables

<Steps>
  <Step title="Add Variables to Prompt">
    ```
    This is your agent Sam speaking.

    May I confirm if your name is {customer_name} and you called us on 
    {last_contacted_on} to enquire about your order item {product_name}.

    Use the call's id which is {call_sid} to automatically transfer the call to a human when the user asks.
    ```
  </Step>

  <Step title="Pass Values via API">
    ```bash theme={"system"}
    curl --request POST \
      --url https://api.bolna.ai/call \
      --header 'Authorization: Bearer <token>' \
      --header 'Content-Type: application/json' \
      --data '{
      "agent_id": "123e4567-e89b-12d3-a456-426655440000",
      "recipient_phone_number": "+10123456789",
      "from_phone_number": "+1987654007",
      "user_data": {
        "customer_name": "Caroline",
        "last_contacted_on": "4th August",
        "product_name": "Pearl shampoo bar"
      }
    }'
    ```
  </Step>

  <Step title="Result">
    The prompt becomes:

    ```
    This is your agent Sam speaking.

    May I confirm if your name is Caroline and you called us on
    4th August to enquire about your order item Pearl shampoo bar.

    Use the call's id which is PDFHNEWFHVUWEHC to automatically transfer the call to a human when the user asks.
    ```

    <Info>
      `call_sid` is automatically injected as a default variable.
    </Info>
  </Step>
</Steps>

***

## Related Features

<CardGroup cols={2}>
  <Card title="Custom Functions" icon="code" href="/tool-calling/custom-function-calls">
    Use context variables in function calls for dynamic actions
  </Card>

  <Card title="Hangup Messages" icon="phone-hangup" href="/hangup-calls">
    Add personalized hangup messages with context variables
  </Card>

  <Card title="Call Details" icon="clipboard-list" href="/using-extractions">
    Extract context data from call details
  </Card>

  <Card title="Multi-Agent" icon="users" href="/multi-agent-prompt">
    Build multi-agent workflows with shared context
  </Card>
</CardGroup>
