Skip to main content

Examples of Expression Conversion and Evaluation

This page explains how to use expressions and filters in each workflow step, along with use cases and input/output examples.

For the filter syntax and full list, see Expression Conversion and Evaluation Filters.

Basics of Pipe Notation

Filters are applied from left to right in order using |.

A | f1 | f2 means that f2 is applied to the result of applying f1 to A.

Examples:

ExpressionWhat it does
{{ name | to_lower }}Converts the value of name to lowercase.
{{ text | contains "abc" }}Determines whether text contains "abc".
You can also chain multiple filters.

As shown below, write them in the order they should be processed from left to right.
{{ message | to_lower | contains "error" }}
{{ input_path | path_basename | to_upper }}

The following sections explain specific processing examples.


JSON Conversion

Use the following two filters as a pair depending on the purpose.

  • from_json: Converts a string into an object
  • to_json: Converts an object into a string

Convert a String into an Object

There are cases where AI extracts information from text and returns the result as JSON-formatted text.
In that state it is just a string, but using from_json allows it to be handled as an object.

Use Cases

  • When you want to reference properties after an llm step returns JSON-formatted text
  • When you want to use a JSON string read from an external file in subsequent conditions or variable references

Example

{{ llm_response | from_json }}

In this case, the value is set as properties such as name and priority, as shown below.

Input (llm_response)Converted result
{"name":"alice","priority":"high"}{name: "alice", priority: "high"}

After conversion, you can reference it in subsequent steps as follows.

{{ extracted.priority == "high" }}
{{ extracted.name }}
info

Result variables from a tool step are automatically converted into objects, so from_json is not required.
This is mainly used when you want to explicitly convert JSON-formatted text such as AI output or the result of reading an external file.

Convert an Object into a String

When you want a later AI step to summarize a tool execution result, it can be difficult to embed an object directly into a prompt.
In that case, convert it into a string with to_json.

Use Cases

  • When you want to embed the result of a tool step into the prompt of an llm step
  • When you want to pass an object-type variable into a text input field

Example

{{ tool_result | to_json }}

In this case, the value is set as a string using keys such as "name" and "priority", as shown below.

Input (tool_result)Converted result
{name: "alice", score: 90}{"name":"alice","score":90}
By setting options, you can also include null.

If specified as follows, it outputs {"name":"alice","score":null}.
{{ tool_result | to_json { ignoreNulls: false } }}


String Matching

Use the following methods to determine string matches.

  • contains: Partial match
  • starts_with: Prefix match
  • ends_with: Suffix match

The return value is true or false.

All of them are case-sensitive.

If you want to compare without case sensitivity, use to_lower in advance.

Partial Match

contains determines whether a specific string is included in a string.

Use Cases

  • When you want to determine in an if step whether a response contains a keyword
    • For example, branching when "error" is included.
  • When you want to check whether expected terms are included in LLM output

Example

{{ responseBody | contains "World" }}
Input (responseBody)Result
"World"true
"world"false
When you do not want to distinguish uppercase and lowercase

If you use responseBody | to_lower | contains "World", both cases become true.

Prefix Match

starts_with determines whether the beginning of a string matches the specified string.

Use Cases

  • When you want to determine whether a status code starts with 2 and treat it as a 2xx success response
  • When you want to check whether a URL starts with https://
  • When you want to branch processing based on the prefix of an ID or code
  • When you want to check whether a file path starts with a specific folder

Example

{{ statusCode | starts_with "2" }}
Input (statusCode)Result
"200"true
"404"false

Suffix Match

ends_with determines whether the end of a string matches the specified string.

Use Cases

  • When processing a file list in foreach and you want to target only files with a specific extension
  • When you want to branch processing by file type such as .csv, .json, or .txt
  • When you want to check whether an output file name ends with the expected extension

Example

{{ file | ends_with ".csv" }}
Input (file)Result
"report.csv"true
"report.xlsx"false

Path Operations

Use the following methods to retrieve and modify file paths.

  • path_filename: Extract the file name including the extension
  • path_basename: Extract the file name without the extension
  • path_join: Join path elements
  • path_normalize: Normalize path notation

Extract the File Name Including the Extension

path_filename extracts only the file name including the extension from a full path.

Use Cases

  • When processing a list of full paths in foreach
  • When you want to embed only a short file name into a notification or prompt

Example

{{ input_path | path_filename }}
Input (input_path)Result
C:\work\reports\sales.csvsales.csv

Extract the File Name Without the Extension

path_basename extracts the file name without the extension from a path.

Use Cases

  • When you want to create an output file with the same name as the input file but with a different extension
  • When you want to use the file name as part of a key name

Example

{{ input_path | path_basename }}
Input (input_path)Result
C:\work\reports\sales.csvsales

Join Path Elements

path_join is a filter that joins multiple path elements into a single path.

tip

Compared with creating a path by concatenating strings, using path_join makes the intent clearer and is safer to handle.

Use Cases

  • When you manage the output folder and file name in separate variables
  • When you do not want to manually enter the path separator (/)
  • When you want to build a path by combining a subfolder name or date folder name

Example

{{ [output_dir, sub_dir, file_name] | path_join }}
InputResult
output_dir: ["C:\work",
sub_dir: "logs",
file_name: "app.log"
C:\work\logs\app.log

Normalize Path Notation

path_normalize resolves . and .. contained in a path and normalizes its notation.

info

path_normalize does not check whether the file exists. It only normalizes the path string itself.

Use Cases

  • When you want to clean up a path built with path_join before passing it to subsequent processing
  • When user input may contain ..

Example

{{ raw_path | path_normalize }}
Input (raw_path)Result
C:\work\..\logs\app.logC:\logs\app.log