Dynamic Content and Contexts

Several cells allow you to dynamically build content, from Answers to Gen AI prompts and more. This page will assist you to fully understand Syntphony CAI's capabilities for creating Dynamic Content.

About Dynamic Content

Certain fields in Syntphony CAI cells partially comply with JavaScript syntax. This enables you to reference variables anywhere in your content, allowing it to be dynamic.

When working with Syntphony CAI, you can utilize three types of context variables to handle different kinds of information based on security requirements and data manipulation needs, allow you to access user inputs, recognized metadata from the previous interaction, and generated or processed content from other cells.

All context information is transmitted via API through transactional responses, REST API connectors, or webhooks.

Using Dynamic Content

You can insert the variables in your texts preceded by the symbol '$' (dollar sign) and Syntphony CAI will convert their values on the fly during the conversation.

The '$' symbol is required on most cells, unless specified. The table below illustrates the cells that support Dynamic Content and the associated set of fields that empower you to use this feature.

Cell
Fields that allow Dynamic Content
  • Answer templates

  • All button texts

  • Technical text

  • For transactional answers: webhook URL and headers. Additionally, all contexts and their variables will be available within the received body on your end.

  • Prompt field only

  • Webhook URL

  • All headers

  • URL

  • All headers

  • Body

  • Every field in the Authentication section

  • Output field

Code cells can use all Dynamic Content features, but with a distinct text notation: it doesn't require the '$' character preceding variables. Refer to its page for more examples.

Like in the Code cells, Rule cells can use all Dynamic Content features, but with a distinct text notation: doesn't require the '$' character preceding variables. Refer to its page for more examples.

If you're familiar with coding, you can write more complex structures, such as conditional clauses and text operations.

To predict different answers to different variables and parameters, you can use Answer cells as a printing tool for development purposes.

Dynamic Content execution in Syntphony CAI uses the The Apache Velocity Project. Refer to its page for notation and code structure.

Supported variables

Besides the default variables, Syntphony CAI has 3 separate contexts which are, essentially, variable holders for you to store anything you wish during a conversation.

Data stored on those variables will persist between flows and AI agents and are short-memory, session-exclusive, meaning any value attributed to a conversation only exists there. They are as follow:

Variable
Function
Syntax/Notation

Intents

Stores the last recognized intents, most accurate first and least accurate last, in a list.

$intents[0]

(Obs.: The formula remains unchanged regardless of the Intent's name)

Entities

Stores the last recognized entities, in a list.

$entities['entity's_name']['0']

Text

Stores the last text sent by the user

$text

Information about the virtual agent (bot)

Contains the virtual agent name

$info.bot

Information about the channel

Contains the given name for the currently used channel

$info.channelName

Information about the channel type

Contains the current channels type (whether its web, Facebook, Alexa, etc.)

$info.channelType

OS

Information about the user's operating system. Example: for web chat, it might be Windows; and for a mobile app, iOS

$info.operatingSystem

OS-Version

Information about the version of the operating system above

$info.operatingSystemVersion

Browser

Includes the user’s current browser, if applicable

$info.browser

Browser-Version

Contains user’s current browser-version, when using one

$info.browserVersion

User-Ref

Contains the user’s identification through a technical value, depending on the channel. Some examples:

- For web chat: the user IP address

- IVR: phone number

- Messenger: Facebook’s user ID

$info.userRef

Business-key

Contains the user’s identification in a business level if the channel has information about the user. Examples:

- In a private section of a webpage that requires logging in, the business key might be the user login

- User document number

- Client #

$info.businessKey

Locale

Contains the virtual agent’s language: <language>-<COUNTRY>

This must be the same as configured in the Cockpit.

Examples: en-US es-ES pt-BR

$info.locale

Channel Classification

Contains the category of the existing channel in the channel library.

$info.channelClassification

Session Code

Contains the UUID/GUID of ongoing conversations. It's empty before user's first input.

$sessionCode

Code

Stores the code of the last message (unprocessed, raw input).

$code

Parameter

Contains the parameters you have setup in Syntphony CAI - both virtual agent parameters and environment parameters. In the event that there is a parameter with the same name in both lists, the bot parameter will take precedence. Learn more about Parameters

$parameters['parameter's_name']

Store user-defined variables, with distinct readability rules.

$openContext.field $visibleContext.field $hiddenContext.field

Sub-variables

Some of the variables have nested variables, i.e., variables within themselves. See the examples below:

Intent

Variable
Function
Formula/Notation

Name

Name of the intent, same as the NLP.

$intents[0].name

Confidence

Confidence score returned by the NLP, this will be a percentage number from 0 to 1.

$intents[0].confidence

Entity

Variable
Function
Formula/Notation

Name

Name of the entity, same as the NLP.

$entities['entity's_name']['0'].name

Value

The value of the entity returned by the NLP

$entities['entity's_name']['0'].value

Position

Position of the string within the user input (text)

$entities['entity's_name']['0'].position

originalValue

Original value of the user's text that corresponds to the detected entity

$entities['entity's_name']['0'].originalValue

Using Contexts

As a AI agent developer, one may find it difficult to keep track of different variables while maintaining the context and natural flow of a conversation.

Syntphony CAI helps you capture and reuse contextual data for a large variety of scenarios, so you can create more complex use cases and redefine the enterprise customer experience, through the context variables.

The context's saved data is only available during the session, meaning that it is lost when the session code expires.

All contexts coexist throughout the conversation. Because they are the only way to store your custom variables, it is expected that each context will contain several nested variables (sub-variables), as illustrated below:

$openContext.yourVariable

$openContext.yourVariable.subValueA

$openContext.yourVariable.subValueB

$openContext.yourOtherVariable

[etc...]

Understanding how the context works is one of the most essential parts of Syntphony CAI. It is possible to use 3 different types of context: open, visible and hidden.

Open context

Used to handle dynamic data that users can interact with and modify during the conversation flow, and it's shared in all integrations.

Security Level: Lower. Data can be manipulated and updated based on user interactions. Channels that integrate with Syntphony CAI are considered insecure and this is the only place where they can manage information in Syntphony CAI’s context.

If you are integrating with third party channels, you may need to use this context if you want your channel to access and also modify a variable, but you should only do so when strictly necessary. We encourage you to modify Syntphony CAI's variables with it's tools, such as Code and Rest Connector cells, instead.

Use Cases: Recording that a user has selected products 1 and 2 for purchase, allowing the system to update quantities or remove items as needed. Other examples:

  • Shopping cart contents and selections

  • Form inputs and user preferences

  • Interactive survey responses

  • Temporary session data

  • User-generated content

Visible context

The visible context is available for everyone, but channels are not able to change its content. It is essentially a read-only public context. Information that might be used by the channels but also impacts the conversation flow, service calls and overall functioning of the agent must be added here.

Security Level: Medium. Data is accessible for viewing but protected from manipulation.

Use Cases: Showing a list of current promotional products from an ecommerce platform that users can view but not alter. Other examples:

  • Product catalogs and pricing information

  • Promotional offers and discounts

  • Public company information

  • Weather data or news feeds

  • System status and notifications

  • Reference materials and documentation

  • Order history and transaction records

Hidden context

The most secure out of the three. Hidden context is only visible - and editable - using Service, Prompt and Rest cells.

Security Level: Highest. Data remains completely private and secure within the system. Any content executed by Syntphony CAI on any channel can access data stored here. The integrations and channels themselves are those which have their access restricted.

Use Cases: Storing a user's credit card information during a payment process without exposing it to the conversation flow. Other examples:

  • Personal identification numbers (national ID numbers)

  • Banking and financial information (account numbers, credit card details)

  • Authentication credentials (passwords, API keys, tokens)

  • Medical records or health information

  • Confidential business data

  • Personal addresses and contact details

Data Transmission

All context variables are transmitted through:

  • API Responses: Direct data exchange between systems

  • REST Connectors: Standard web service integration

  • Webhooks: Real-time event-driven data delivery

Choose the appropriate context type based on your data sensitivity requirements and whether the information needs to be readable or modifiable by end users.

Storing data on Contexts

There are several variables you may use cooked directly into Syntphony CAI, as abovementioned. Besides that, you can store and read data on the three available contexts which are, essentially, variable holders for you to store anything you wish during a conversation.

Context variables can have data stored into them through specific cells, as follows:

Cell
Can store

Every Input cell has a "Remember Input" switch. By enabling it and naming a variable, that current user input is stored as-is in the Visible Context under that variable name.

Can read, create and modify existing variables in all contexts without any restrictions. Any code you execute or validation you perform may store their results on persisting variables within any of the three contexts.

They can be used to parse existing values in contexts and update them or save data on new fields.

e.g.: hiddenContext.myValue = 5;

The Prompt cell has a mandatory naming field called "Variable". On execution, the generated content is stored in a variable of that name in the Hidden Context.

The Rest Connector cell has a body field like in the Code cell, called Output. This field can perform any operation that a code cell could. Additionally, the result of the Web Request can be found, as received, in the Hidden Context under the name "RestConnectorResponse".

(hiddenContext.RestConnectorResponse)

Note that none of the above store any data in Open Context by default, and only Input cells store data into Visible Context - because user input is something the your channels already have access to.

Unnecessary data sharing

If you are integrating with a specific channel or platform that requires access and/or modification of your variables, but also have channels that do not require so, you may wish to avoid having that data shared with your other unrelated channels.

Last updated

Was this helpful?