Ensemble Docs

Usage

Expressions, variables, and response transformation

Tool Usage

Accessing Variables

Tools can access data through expressions in configuration fields like URLs, headers, body, and queries.

Input Variables

Input variables defined on the tool are accessed directly by name:

${customerId}
${orderDate}
${items[0].name}

Context Variables

Context passed from the chat client (via dataContext or JWT) is accessed via context.*:

${context.environment}
${context.userPreferences.theme}

User Context

System user information is accessed via userContext.*:

${userContext.userId}
${userContext.tenantId}

Expression Languages

Tools support two expression syntaxes. Do not mix them in the same template.

JEXL (Default)

Use ${...} syntax for JEXL expressions:

https://api.example.com/users/${userId}/orders
${items | filter('status', 'active') | length}

JEXL supports transforms, conditionals, and array operations.

LiquidJS

Use {{...}} syntax for LiquidJS templates:

Hello {{context.userName}}, your order #{{orderId}} is ready.
{% if items.size > 0 %}{{items | first | json}}{% endif %}

LiquidJS is better for string templating with conditionals and loops.

Response Transformation

Transform tool output before the agent sees it. Useful for extracting relevant data from large API responses.

Enable "Transform Result?" in the tool configuration, then add one or more transform steps.

Extract Path

Extract a nested value from the response.

FieldDescription
PathPath to the data (e.g., data.results, items[0].name)

Example: Path data.results

Input:

{"status": "ok", "data": {"results": [{"id": 1}, {"id": 2}]}}

Output:

[{"id": 1}, {"id": 2}]

Array to Map

Convert an array into an object keyed by a field.

FieldDescription
Array PathPath to the array (leave empty for root)
ID FieldField in each item to use as the key

Example: Array Path users, ID Field id

Input:

{"users": [{"id": "a", "name": "Alice"}, {"id": "b", "name": "Bob"}]}

Output:

{"a": {"id": "a", "name": "Alice"}, "b": {"id": "b", "name": "Bob"}}

Chaining Steps

Add multiple transform steps to create a pipeline. Each step receives the output of the previous step.

On this page