> For the complete documentation index, see [llms.txt](https://docs-conversational-ai.syntphony.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-conversational-ai.syntphony.com/studio/parameters-and-variables/dynamic-content-and-contexts.md).

# Dynamic Content and Contexts

## Dynamic Content

Allows supported Syntphony Conversational AI fields to use values that are resolved during execution.

Instead of writing only fixed text, you can insert a value from a Parameter, Variable, Context, Intent, Entity, or System Variable. At runtime, Syntphony Conversational AI replaces the expression with the current value.

Use Dynamic Content to:

* Personalize answers;
* Reuse Parameters in URLs or messages;
* Use the last user input;
* Reference recognized intents and entities;
* Adapt AI Agent, Supervisor, Persona, Action, Collection, and Wait Input behavior with current session data;
* Pass values between cells through contexts.

### How it works

In most supported fields, use the `$` prefix. For instance:

```
$Text
$intents[0].name
$openContext.cart.total
${first_name}
$api_base_url
```

If `quantity` is a Variable that references `openContext.quantity`, use:

```
$quantity
```

when referencing the Variable in supported fields.

In **Code and Rule cells**, use native syntax without `$`.  For example:

```
openContext.quantity > 5
```

{% hint style="info" %}
Dynamic Content is supported **only in fields that display support for dynamic values or the Parameters & Variables selector.**
{% endhint %}

### Runtime values available for Dynamic Content

| Value type      | Example syntax                      | Use it to                                                                                                |
| --------------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------- |
| User input      | `$Text`                             | Use the last message sent by the user.                                                                   |
| Intent          | `$intents[0].name`                  | Use the highest-ranked recognized intent.                                                                |
| Entity          | `$entities['destination'][0].value` | Use a value extracted from the last user input.                                                          |
| Parameter       | `$api_base_url`                     | Use a Project Parameter or Environment Parameter.                                                        |
| Context value   | `$customer_id`                      | Use data stored during the session. The example assumes a Variable named `customer_id` has been created. |
| System metadata | `$ChannelName`                      | Use runtime information provided by Syntphony Conversational AI.                                         |

### Where Dynamic Content can be used

Dynamic Content can be used in supported fields across different areas of Syntphony Conversational AI:

<table data-search="false"><thead><tr><th>Area</th><th>Typical supported use</th></tr></thead><tbody><tr><td>Answer and Question</td><td>Personalize answer templates, buttons, quick replies, technical text, and supported Webhook configuration fields.</td></tr><tr><td>Prompt</td><td>Build prompts using current conversation data.</td></tr><tr><td>Webhook and REST Connector</td><td>Compose URLs, headers, body content, authentication values, and response handling fields.</td></tr><tr><td>Code and Rule</td><td>Read or evaluate context values using native syntax.</td></tr><tr><td>Supervisor and AI Agent</td><td>Adapt goal, instructions, guardrails, and rules using session data.</td></tr><tr><td>Persona</td><td>Adapt personality or backstory using contextual information.</td></tr><tr><td>Action</td><td>Use values in descriptions, parameter descriptions, rules, and advanced parameters.</td></tr><tr><td>Collection and Wait Input</td><td>Use values in supported description, Pattern, <code>callToAction</code>, and Stored fields.</td></tr></tbody></table>

## Contexts

Contexts are session-based containers for conversation data. The data remains available during the session and is lost when the session code expires.

If you want more information specifically about Contexts applied to AI Agents, [**check in here**](https://docs-conversational-ai.syntphony.com/studio/ai-agents/actions/context-variables.md#context-types).

#### Best to use each context

| Context         | What it means                                                  | Best use                                       |
| --------------- | -------------------------------------------------------------- | ---------------------------------------------- |
| Open Context    | Readable and editable by the end user.                         | Use only when a channel must update the value. |
| Visible Context | Readable and editable by channels. Read-only for the end user. | Use when a channel needs to view the value.    |
| Hidden Context  | Available to channels. Hidden from the end user.               | Use for private or sensitive information.      |

{% hint style="info" %}
Storing data in Open Context or Visible Context shares that data with integrated channels. Store sensitive information only in Hidden Context.
{% endhint %}

### Storing data in contexts

Some cells can store or update context values.

| Cell           | What it can do                                                                                                     |
| -------------- | ------------------------------------------------------------------------------------------------------------------ |
| Input          | Stores the current user input in Visible Context when **Remember Input** is enabled.                               |
| Prompt         | Can stores generated content in Hidden Context using the configured variable name.                                 |
| REST Connector | Can process response data. The raw web request response is available in Hidden Context as `RestConnectorResponse`. |
| Code           | Can read, create, and update context values.                                                                       |
| Rule           | Can evaluate context values to decide which path the flow follows.                                                 |

### Avoid unnecessary data sharing

Code cell work with information available in Syntphony Conversational AI's system and allow creating Variables.

Use the most restrictive Context that supports the use case.

For example, if only one channel needs access to a value, create a channel-specific branch and use a Rule cell to check the current channel, like:

```
$ChannelType == 'Web'
```

But, you can also use:

```
$ChannelName
$ChannelType
```

{% hint style="info" %}
This helps avoid sharing data with channels that do not need it.
{% endhint %}

### Context practical examples

#### Personalize an answer:

```
Hello, ${first_name}. Your account type is ${account_type}.
```

#### Use the last user message:

```
You typed: $Text
```

#### Use a shared API URL:

```
$api_base_url/customers/${customer_id}
```

#### Use an entity value:

```
Your destination is $entities['destination'][0].value.
```

#### Use a context value in a Rule:

```
openContext.quantity > 5
```

#### Store private data in Hidden Context:

```
$customer_id
```

### Troubleshooting

| Issue type | Problem                                                    | What to do                                                              |
| ---------- | ---------------------------------------------------------- | ----------------------------------------------------------------------- |
| Noise      | A value does not resolve.                                  | Check the syntax, field support, and whether the item is enabled.       |
| Noise      | A Rule condition fails.                                    | Use native syntax without `$`, such as `openContext.quantity > 5`.      |
| Obstacle   | A value is visible to a channel that should not access it. | Move the value to Hidden Context and review integration behavior.       |
| Obstacle   | A shared Parameter changed more than expected.             | Check whether it is an Environment Parameter used by multiple projects. |
| Blocking   | A deleted Parameter or Variable is still needed.           | Recreate the item or update the affected field manually.                |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs-conversational-ai.syntphony.com/studio/parameters-and-variables/dynamic-content-and-contexts.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
