Conditions

The Conditions defined within an Edge define the criteria that must be met for an Edge to be traversed. Conditions guide the agent’s decisions by assessing input data or external responses. If the Conditions are met, the agent proceeds along the defined Edge to the next Turn or Block.

 

Types of Conditions

Block Agents support two types of Conditions:

  • Expression-Based Condition

    • The expressions in a JSON object are evaluated. The structured data can be from tools or external systems.

  • Loop-Based Condition (Natural Language Understanding (NLU))

    • This Condition type is typically used for Edges with the “type”: “loop”, designed for fallback scenarios where the agent’s response relies on understanding natural language input. These conditions leverage LLMs and NLU capabilities to interpret if the user’s response semantically matches the Condition and then determine the appropriate next action.

Note: The Condition types are mutually exclusive. You cannot mix both Condition types within a single Turn. The only exception to this rule is when an Edge is a “loop” type. In this case, a Loop-Based Condition is allowed alongside an Expression-Based Condition. This enables fallback scenarios where both structured evaluation and NLU can be used.

 

Expression-Based Condition Properties

Property

Description

source

Specifies the source of the data to be evaluated. Supported values are:

  • tools: The condition evaluates data captured by tool calls within in the current Turn.

  • external: The Condition evaluates data provided from an external system (usually in a wait Turn), such as results from an authentication call, payment status, etc.

expected_value

Defines the expected result against which the source data is compared. This field supports case-insensitive string equality with wildcard matching (i.e., *).

The Condition is considered met when the source data matches the expected value

 

NLU Condition Properties

Property

Description

nlu

The word or phrase the caller's response is compared to. The Condition is considered met when the user's response semantically matches the data here.

 

Sample Conditions

A Tool Condition might look like this:

condition:
	source: tools
	expected_value:
		schedule_appointment: true
		arg_is_existing_patient: true
	transition_prompt: Use this when the user wants to schedule an appointment or exam.

 

An External Condition might look like this:

condition:
	source: external
	expected_value:
		date_of_birth_lookup: schedule_appointment
	transition_prompt: Since it is before 2pm, transfer the user to the team.

 

An NLU Condition might look like this:

condition:
	nlu: "Once the user affirms this is the correct appointment."

 

Bonus Condition Configurations

The following features can also be included in your Condition configuration, depending on your use case, and are not required.

 

Regex

Regex patterns are supported for flexible matching. A Condition incorporating Regex might look like this:

condition:
	source: tools
	expected_value:
		birth_year: '[0-9]{4}'
		birth_month: '[0-9]{2}'
		birth_day: '[0-9]{2}'
		date_of_birth: '[0-9]{4}-[0-9]{2}-[0-9]{2}'
	transition_prompt: Use this when you have collected the full birthdate.

In this example, the Condition matches when all date components follow the expected patterns ((4-digit year, 2-digit month, 2-digit day, full ISO date format).

 

Wildcards

Incorporate an asterisk (*) as a wildcard matcher in your Condition configuration. An example might look like this:

condition:
	source: tools
	expected_value:
		transfer_to_agent: true
		transfer_reason: '*'
	transition_prompt: Use this when user asks to speak to an agent/human.

In this example, any transfer_reason value would be considered a match as long as the transfer_to_agent is true.

 

Operators

Similar to what you read about with Edges, Conditions can also include the and/or operator.

By default, and is used for multiple expected values and all elements must be true to satisfy that Condition. When you use the or operator, that Condition is considered to be satisfied if any of the elements are true.

An example might look like this:

condition:
	source: tools
	expected_value:
		schedule_appointment: true
		cancel_appointment: true
	operator: or
		transition_prompt: Use when user wants to schedule OR cancel.

 

Tips

  • Conditions are mutually exclusive: Expression-Based and Loop/NLU-Based Conditions cannot be mixed within a single Turn, except when using loop Edges.

  • Only one loop per Turn: Each Turn should only have one loop Edge to ensure clear fallback behavior.

  • Oder matters: Edges are evaluated in the order they are listed. The first matching Condition wins.

 

Next up, learn more about Block Agent Tools.