# Context variables

## Context variables

In the agentic workflow architecture, variables play a crucial role in managing context across interactions.&#x20;

{% hint style="success" %}
Learn more about all the [supported variables ](/user-guide/build-dialogs/dynamic-content-and-contexts.md#supported-variables)in Syntphony CAI
{% endhint %}

When an action captures data, it's stored in the conversation context and can be accessed using specific variable structures, as seen in the examples below.

<table data-header-hidden><thead><tr><th width="272.20001220703125" valign="top"></th><th width="324.199951171875" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><strong>Agentic Variables</strong></td><td valign="top"><strong>Description</strong></td><td valign="top"><strong>Where</strong></td></tr><tr><td valign="top"><code>hiddenContext._</code><br><code>eva.api.agentic.functionRequest</code></td><td valign="top">Internal key for passing parameters to a Rest call</td><td valign="top">Field <a href="/pages/PQ1TJS6Ii2m3cTjaZWwQ#parameters">Parameters inside Actions</a></td></tr><tr><td valign="top"><code>hiddenContext._</code><br><code>eva.api.agentic.functionResult</code></td><td valign="top">Used to store the result of a request to an endpoint in the context</td><td valign="top"><a href="/pages/nD2EJS2OjDUL4VGV158h#rest-connector">Service cells</a></td></tr><tr><td valign="top"><code>hiddenContext._</code><br><code>eva.api.agentic.userData</code></td><td valign="top">Pass information in context (e.g. ID number, email, etc.) or any relevant information to the agent. It can be any data type.</td><td valign="top"><a href="/pages/nD2EJS2OjDUL4VGV158h#rest-connector">Service cells</a></td></tr></tbody></table>

These variables create a dynamic memory system that persists information between agent interactions. By properly structuring your Code cells to read from and write to these context objects, you can build sophisticated workflows where each action builds upon previously collected information.

## Manipulating Context

When an action captures data, it's stored in the conversation context and can be accessed using specific variable structures using [Code cells](/user-guide/build-dialogs/dialog-cells/code.md).

### User Data&#x20;

For scenarios requiring proactive API queries or leveraging data captured outside the Agentic context, you can manually insert contextual user data without waiting for a direct action call. The variable `hiddenContext._eva.api.agentic.userData` is used to set the user (customer) data for the agent. After setting the information in the context, the next call to OpenAI will send the user data and the request (text) from the client.

<figure><img src="/files/xYFsVbLQpKFtUjgJtqgH" alt=""><figcaption><p>User data example</p></figcaption></figure>

Note that `userData` is specifically structured as an object with key-value pairs { key: value }, while `functionResult.result_data` is flexible and can contain any data type returned from the API call, allowing for versatile data handling in your Code cells.

### Success Scenario

When an Action is successfully executed:

* The customer request is comprehended and routed to the specialist agent
* Context and supporting data are transmitted to said agent
* The agent identifies the appropriate action/tool
* Function request data is inserted into context (hiddenContext.\_eva.api.agentic.functionRequest)
* A request is made to the client API through a Code cell (formatting) and REST cell (execution)
* Results are stored in context for agent processing

Example of context manipulation to Check Balance:

<figure><img src="/files/JuJ7uIcrQNiMlaolbAAW" alt=""><figcaption><p>Success example</p></figcaption></figure>

### Error Handling

Follows the same structure as the success scenario, with little changes to the last Code cell. Initial Agentic Flow + Function Error:

<figure><img src="/files/FJTvUGl6KXLT9BcqSRCB" alt=""><figcaption><p>Error example</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.conversational-ai.syntphony.com/user-guide/ai-agents/actions/context-variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
