> This page is for Voice APIs.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://dev.hume.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://dev.hume.ai/_mcp/server.

# Dynamic Variables

Dynamic variables are placeholders you put in the [system prompt](/reference/speech-to-speech-evi/prompts/create-prompt),
that you can fill with specific values at the beginning of the chat, and update to new values as the chat progresses.
They are especially useful for giving EVI context that might change depending on the user or on the session - like the
date, the user's name  role, or account balance, or any other dynamic or session-specific information.

### Using variables in your prompt

To set up dynamic variables, first include placeholders for them in your system prompt. Use double curly braces
(\{\{variable_name}}) to mark where each variable should appear in the text. This allows EVI to replace these
placeholders dynamically with the specified values.

#### Sample prompt with dynamic variables

```mdx
Address the user by their name, {{name}}.
If relevant, reference their age: {{age}}.
It is {{is_philosopher}} that this user is a philosopher.
```

> **Info**
>
> Visit our [prompting guide](/docs/speech-to-speech-evi/guides/prompting#using-dynamic-variables-in-your-prompt) for
> more details on adding dynamic variables to your prompt.

### Assigning values in session settings

After adding placeholders for dynamic variables in your prompt, set their values by sending a Session Settings
message over the WebSocket within an active Chat session. This message includes a
[variables parameter](/reference/speech-to-speech-evi/chat#send.SessionSettings.variables), with each
key matching a placeholder in your prompt and each value specifying the text EVI will use.

#### Session settings

```json
{
  "type": "session_settings",
  "variables": {
    "name": "David Hume",
    "age": 65,
    "is_philosopher": true
  }
}
```

> **Info**
>
> Variable values can be strings, numbers, or booleans; however, each value is ultimately converted to a string when
> injected into your system prompt.

To ensure dynamic variables are recognized correctly, follow these guidelines:

* **Only assign values to referenced variables**: If a variable is given a value in the "variables" field but is
  not referenced in the system prompt, EVI will not use it in the conversation.
* **Define all referenced variables**: If a variable is referenced in the system prompt but lacks a value in the
  `variables` field, warning `W0106` can be expected: `"No values have been specified for the variables [variable_name], 
  which can lead to incorrect text formatting. Please assign them values."` This warning is also expected if there
  are spelling inconsistencies between the variable names in `variables` and those in the prompt.

### Default dynamic variables

Hume provides built-in dynamic variables that are automatically populated and can be referenced in system prompts
without needing to set their values in `SessionSettings`. The currently supported default variable is:

* **now**: The current UTC datetime (e.g., `"Nov 08, 2024 09:25 PM UTC"`)

  You can reference `now` in your system prompt to dynamically include the current UTC date and time, as shown below.

  #### Time-aware prompt example

  ```xml
  The current datetime is {{now}}. Mention this time at the start of 
  the call, or if the user asks what time it is. Convert this UTC 
  datetime to other time zones if requested.
  ```

If you set a custom value for a default variable in `SessionSettings`, it will override the default value. For
example, specifying a value for `now` in `SessionSettings` will replace the automatic UTC datetime with your custom
value, offering flexibility when needed.

---