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

# Context

> The context encompasses the dynamic information accessible to the agent during a call, which is crucial for personalizing the interaction and improving the user experience. This data enriches the voice agents' prompts through templating and is also transmitted during workflow-type actions during the call, as well as in the post-call webhook.

## System Context

The context of each call automatically includes a set of system variables that provide essential information about the ongoing call. These variables are always available and can be used in your prompts, workflows, and integrations.

```json theme={null}
{
  "system": {
    "agentId": "b8d9637f-ba51-4aa2-84a4-80692f7bbd17",
    "callId": "40387944-5065-483f-942c-68bae81e70ec",
    "customerId": "1e1a79ee-c6ec-4b07-89f0-9a414daaa9de",
    "date": "2025-05-13",
    "dayOfWeek": "tuesday",
    "phone": "06 12 34 56 78",
    "phoneE164": "+33612345678",
    "now": "2025-05-13 10:36:37",
    "timeHHMM": "1036",
    "year": "2025"
  }
}
```

| Variable           | Description                                                                                                                            |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
| `system.callId`    | Unique identifier of the ongoing call. Can be used for tracking, logging, or cross-referencing in your systems.                        |
| `system.agentId`   | Unique identifier of the voice agent handling the call. Useful for differentiating agents in analytics or for specific configurations. |
| `system.dayOfWeek` | Current day of the week in customer locale. Allows customizing greetings or availability based on the day.                             |
| `system.phone`     | Phone number of the interlocutor in local format, with spaces. Ideal for display or verbal communication.                              |
| `system.now`       | Current date and time in ISO format, according to the configured time zone. Provides temporal context for the call.                    |
| `system.phoneE164` | Phone number of the interlocutor in E.164 (international) format. Standardized format optimal for database searches or API calls.      |

## Pre-Call Action

Before each incoming or outgoing call, you can enrich the context with additional information by configuring a pre-call action on your agent.
The return of this action will be injected into the call context.
<Tip>Use the caller/called phone number (`system.phoneE164`) from the system context to retrieve customer information from your systems.</Tip>

## Outgoing Call

### API

When creating calls via API, a context can be provided in the request and will be injected during the call.

<Card title="Initiate Outgoing Calls" icon="phone-arrow-up-right" href="/api-reference/calls/create" horizontal>
  View API Reference
</Card>

### Campaigns (Excel / CSV)

For mass outgoing call campaigns, you can provide the context via Excel or CSV files.

<Warning>
  Column names in your Excel/CSV files must not contain spaces or special characters to be correctly transformed into variables. Use underscores (\_) to separate words.
</Warning>

## Incoming Call

### SIP

When receiving an incoming call via a SIP connection, Volubile automatically adds to the call context the `User-to-User` header and all other custom SIP headers starting with `X-Volubile-`. These headers are then available and can be utilized within the prompt.

#### Automatic Conversion

SIP headers are automatically transformed into context variables according to the following rule:

1. The prefix `X-Volubile-` is removed.
2. The remaining key is converted to lowercase.
3. Hyphens (`-`) are replaced by underscores (`_`).

| SIP Header                       | Conversion in Context       |
| -------------------------------- | --------------------------- |
| `User-to-User: 6796`             | `{"user_to_user": "6796"}`  |
| `X-Volubile-code: 123456`        | `{"code": "123456"}`        |
| `X-Volubile-client-id: CL001`    | `{"client_id": "CL001"}`    |
| `X-Volubile-offer-type: premium` | `{"offer_type": "premium"}` |

#### Complete Example

<CodeGroup>
  ```http Received SIP Headers theme={null}
  User-to-User: 6796
  X-Volubile-code: ABC123
  X-Volubile-client-id: CL-45678
  X-Volubile-client-segment: premium
  X-Volubile-campaign-id: CAMP-2025-Q2
  ```

  ```json Generated Context theme={null}
  {
      "user_to_user": "6796",
      "code": "ABC123",
      "client_id": "CL-45678",
      "client_segment": "premium",
      "campaign_id": "CAMP-2025-Q2"
  }
  ```
</CodeGroup>
