# Context variables

## What are *Context variables*?

*Context variables* allow for conversational AI to retain information about something without the need to run API calls or ask users repeat questions. These variables are intended to be collected and [set in a flow](https://docs.nlx.ai/platform/nlx-platform-guide/overview/nodes#add-functionality) then used throughout a session to better route users or personalize the conversation, including context passed along during escalation events.&#x20;

Within the *Context variables* resource, you create the name and define the data type of the context variable, allowing you to reference it in any flow across your workspace as you design your conversations.&#x20;

For example, after authenticating a user, you can reference a context variable that sets their authentication status as "true." In any flow that requires an authenticated person to complete a process, [conditional logic](https://docs.nlx.ai/platform/nlx-platform-guide/overview/nodes#split) can simply check the context variable rather than re-running a series of steps with the user to determine this context.

Other examples that may be collected once from user input or an API call and set for the duration of the conversation session:

* User information, including name, address, ID, email, reward/member tier, DOB, etc.
* Device/phone type
* Issue, topic, or reason
* Confirmation to a specific Yes/No question
* A counter (keeping track of retries, etc.)

{% hint style="info" %}
To create transient context that is not shared across flows or retained for escalation, consider using [the *Define* node](https://docs.nlx.ai/platform/nlx-platform-guide/overview/nodes#define).
{% endhint %}

To access, click *Resources* in your workspace menu and choose *Context variables*:

{% @arcade/embed flowId="D7SCuQ8zP82OH8QSDZJk" url="<https://app.arcade.software/share/D7SCuQ8zP82OH8QSDZJk>" %}

***

## Add a *Context variable*

{% @arcade/embed flowId="GKEkgJvrT3AyZKYvx41f" url="<https://app.arcade.software/share/GKEkgJvrT3AyZKYvx41f>" %}

1. Begin by selecting *+ Add context variable* from the *Context variables* resource:
2. Expand new variable > Enter name
3. Expand *Schema* section > Select data type from the dropdown
   * You may also select the *<> Auto-generate schema* option to input sample JSON for easily constructing a complex schema structure
4. Optional: *Allow client-side updates*: ON by default. Allows values from your frontend (Touchpoint or any client application) to modify the variable. Disable this if the variable should only be updated inside NLX flows
5. Click *Save*

{% hint style="info" %}
Need to edit or delete a context variable? After creating your context variable, you may expand its details to overwrite or delete.
{% endhint %}

***

## Use a *Context variable*

Once a *Context variable* has been created, you may reference it easily in nodes when building a flow by selecting it from placeholder dropdowns or entering an open curly brace { in any  text field. All context variables [in your workspace are color-coded pink](https://docs.nlx.ai/platform/nlx-platform-guide/overview/flows-and-variables#variables-in-flows).


---

# 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.nlx.ai/platform/nlx-platform-guide/flows-and-building-blocks/advanced/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.
