Logic components in Langflow

This Langflow feature is currently in public preview. Development is ongoing, and the features and functionality are subject to change. Langflow, and the use of such, is subject to the DataStax Preview Terms.

Logic components provide functionalities for routing, conditional processing, and flow management.

Use a logic component in a flow

This flow creates a "for each" loop with the Loop component.

The component iterates over a list of Data objects until it’s completed, and then the Done loop aggregates the results.

The File component loads text files from your local machine, and then the Parse Data component parses them into a list of structured Data objects. The Loop component passes each Data object to a Prompt to be summarized.

When the Loop component runs out of Data, the Done loop activates, which counts the number of pages and summarizes their tone with another Prompt. This is represented in Langflow by connecting the Parse Data component’s Data List output to the Loop component’s Data loop input.

A loop text summarizer flow

The output is similar to the following:

Document Summary
Total Pages Processed
Total Pages: 2
Overall Tone of Document
Tone: Informative and Instructional
The documentation outlines microservices architecture patterns and best practices.
It emphasizes service isolation and inter-service communication protocols.
The use of asynchronous messaging patterns is recommended for system scalability.
It includes code examples of REST and gRPC implementations to demonstrate integration approaches.

Conditional router (If-Else component)

This component routes messages by comparing two strings. It evaluates a condition by comparing two text inputs using the specified operator and routes the message to true_result or false_result.

Parameters

Inputs
Name Type Description

input_text

String

The primary text input for the operation.

match_text

String

The text input to compare against.

operator

Dropdown

The operator to compare texts. Options: "equals", "not equals", "contains", "starts with", "ends with", "regex". Default: "equals".

case_sensitive

Boolean

If true, the comparison is case sensitive. This setting is ignored for regex comparison. Default: false.

message

Message

The message to pass through either route.

max_iterations

Integer

The maximum number of iterations for the conditional router. Default: 10.

default_route

Dropdown

The default route to take when max iterations are reached. Options: "true_result" or "false_result". Default: "false_result".

Outputs
Name Type Description

true_result

Message

The output when the condition is true.

false_result

Message

The output when the condition is false.

Operator behavior

The If-else component includes a comparison operator to compare the values in input_text and match_text.

All options respect the case_sensitive setting except regex.

  • equals: Exact match comparison.

  • not equals: Inverse of exact match.

  • contains: Checks if match_text is found within input_text.

  • starts with: Checks if input_text begins with match_text.

  • ends with: Checks if input_text ends with match_text.

  • regex: Performs regular expression matching. It is always case sensitive and ignores the case_sensitive setting.

Component code

conditional_router.py
404: Not Found

Data conditional router

This component is in Legacy, which means it is no longer in active development as of Langflow version 1.3. Use the Conditional router component instead.

This component routes data objects based on a condition applied to a specified key, including boolean validation.

Parameters

Inputs
Name Type Description

data_input

Data

The data object or list of data objects to process.

key_name

String

The name of the key in the data object to check.

operator

Dropdown

The operator to apply for comparing the values.

compare_value

String

The value to compare against (not used for boolean validator).

Outputs
Name Type Description

true_output

Data/List

Output when the condition is met.

false_output

Data/List

Output when the condition is not met.

Component code

data_conditional_router.py
404: Not Found

Flow as Tool

This component is deprecated as of Langflow version 1.1.2. Instead, use the Run flow component.

Parameters

Inputs
Name Type Description

flow_name

Dropdown

The name of the flow to run.

tool_name

String

The name of the tool.

tool_description

String

The description of the tool.

return_direct

Boolean

If true, returns the result directly from the tool.

Outputs
Name Type Description

api_build_tool

Tool

The constructed tool from the flow.

Component code

flow_tool.py
404: Not Found

Listen

This component listens for a notification and retrieves its associated state.

Parameters

Inputs
Name Type Description

name

String

The name of the notification to listen for.

Outputs
Name Type Description

output

Data

The state associated with the notification.

Component code

listen.py
404: Not Found

Loop

This component iterates over a list of Data objects, outputting one item at a time and aggregating results from loop inputs.

Parameters

Inputs
Name Type Description

data

Data/List

The initial list of Data objects to iterate over.

Outputs
Name Type Description

item

Data

Outputs one item at a time from the data list.

done

Data

Triggered when iteration complete, returns aggregated results.

Component code

loop.py
404: Not Found

Notify

This component generates a notification for the Listen component to use.

Parameters

Inputs
Name Type Description

name

String

The name of the notification.

data

Data

The data to store in the notification.

append

Boolean

If true, the record will be appended to the existing notification.

Outputs
Name Type Description

output

Data

The data stored in the notification.

Component code

notify.py
404: Not Found

Pass message

This component forwards the input message, unchanged.

Parameters

Inputs
Name Display Name Info

input_message

Input Message

The message to be passed forward.

ignored_message

Ignored Message

A second message to be ignored. Used as a workaround for continuity.

Outputs
Name Display Name Info

output_message

Output Message

The forwarded input message, unchanged.

Component code

pass_message.py
404: Not Found

Run flow

This component runs a specified flow within a larger workflow with custom inputs and tweaks.

The Run Flow component can also be used as a tool when connected to an Agent. The name and description metadata that the Agent uses to register the tool are created automatically.

When you select a flow, the component fetches the flow’s graph structure and uses it to generate the inputs and outputs for the Run Flow component.

To use the Run Flow component as a tool, do the following:

  1. Add the Run Flow component to the Simple agent flow.

  2. In the Flow Name menu, select the sub-flow you want to run. The appearance of the Run Flow component changes to reflect the inputs and outputs of the selected flow.

  3. On the Run Flow component, enable Tool Mode.

  4. Connect the Run Flow component to the Toolset input of the Agent. Your flow should now look like this:

    A run flow component running a flow
  5. Run the flow. The Agent uses the Run Flow component as a tool to run the selected sub-flow.

Parameters

Inputs
Name Type Description

input_value

String

The input value for the flow to process.

flow_name

Dropdown

The name of the flow to run.

tweaks

Nested Dict

Tweaks to apply to the flow.

Outputs
Name Type Description

run_outputs

List[Data]

The results generated from running the flow.

Component code

run_flow.py
404: Not Found

Sub Flow

This component is deprecated as of Langflow version 1.1.2. Instead, use the Run flow component.

This component integrates entire flows as components. It dynamically generates inputs based on the selected flow and executes the flow with provided parameters.

Parameters

Inputs
Name Type Description

flow_name

Dropdown

The name of the flow to run.

Outputs
Name Type Description

flow_outputs

List[Data]

The outputs generated from the flow.

Component code

sub_flow.py
404: Not Found

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2025 DataStax, an IBM Company | Privacy policy | Terms of use | Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com