Files
flow/docs/docs/Components/if-else.mdx
T
0048c222ce Docs: 1.8 release (#11295)
* langflow-webhook-auth-enable

* add-not-contains-filter-operator

* does-not-contains-operator

* less-redundant-explanation

* docs: add jq and path selection to data operations (#10083)

add-jq-and-path-to-data-operations

* smart transform historical names

* change back to smart transform

* jq expression capitalization/package name

* small edit for clarity of not contains operator

* read/write file component name changes

* docs: add smart router component (#10097)

* init

* add-to-release-notes

* remove-dynamic-output-as-parameter

* Apply suggestion from @aimurphy

Co-authored-by: April I. Murphy <[email protected]>

* Apply suggestion from @aimurphy

Co-authored-by: April I. Murphy <[email protected]>

* Apply suggestion from @aimurphy

Co-authored-by: April I. Murphy <[email protected]>

* Apply suggestion from @aimurphy

Co-authored-by: April I. Murphy <[email protected]>

---------

Co-authored-by: April I. Murphy <[email protected]>

* docs: screenshot audit (#10166)

* remove-unused

* agent-examples

* main-ui-screenshots

* components-screenshots

* combine-web-search-components

* simple-agent-flow-in-playground

* round-screenshots

* my-projects

* combine-data-components

* docs: component paths updates for lfx (#10130)

* contributing-bundles-path

* api-monitor-example

* concepts-components-page

* contribute-components-path

* Apply suggestion from @aimurphy

Co-authored-by: April I. Murphy <[email protected]>

---------

Co-authored-by: April I. Murphy <[email protected]>

* docs: auto-add projects as MCP servers  (#10096)

* add-mcp-auto-auth-as-default-behavior

* Apply suggestion from @aimurphy

Co-authored-by: April I. Murphy <[email protected]>

* Apply suggestion from @aimurphy

Co-authored-by: April I. Murphy <[email protected]>

---------

Co-authored-by: April I. Murphy <[email protected]>
Co-authored-by: Edwin Jose <[email protected]>

* docs: amazon bedrock converse (#10289)

* use-bedrock-converse

* Apply suggestion from @aimurphy

Co-authored-by: April I. Murphy <[email protected]>

* Update docs/docs/Components/bundles-amazon.mdx

---------

Co-authored-by: April I. Murphy <[email protected]>

* docs 1.7 release: add mock data component (#10288)

* add-component-and-release-note

* Apply suggestion from @aimurphy

Co-authored-by: April I. Murphy <[email protected]>

---------

Co-authored-by: April I. Murphy <[email protected]>

* docs: update custom component docs (#10323)

* add-partial

* update-lfx-component-paths

* move-partial

* completed-quickstart

* clean up intro

* try-docker-with-custom-mount

* up-to-typed-annotations

* typed-annotations

* dynamic-fields

* end-of-file

* bundles-naming

* chore: update component index

---------

Co-authored-by: Hanzo Dev <[email protected]>

* docs: add cometapi back for 1.7 release (#10445)

* add-comet-bundle-back-for-1.7

* add-comet-to-release-notes

* docs: add back docling remote vlm for release 1.7 (#10489)

* add-back-docling-vlm-content

* add-release-note

* docs: ALTK component (#10511)

* broken-anchor

* sidebar-and-page

* add-release-note

* add-context-on-output

* docs: SSRF warning (#10573)

* add-ssrf-protection-env-var

* api-request-component

* Update docs/docs/Components/components-data.mdx

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

* move-note-to-table

* release-note

---------

Co-authored-by: April I. Murphy <[email protected]>

* docs: dynamic create data component (#10517)

* add-dynamic-create-data-component-and-release-note

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

* clarify-message-types

---------

Co-authored-by: April I. Murphy <[email protected]>

* docs: cuga component bundle (#10589)

* initlal-content

* cuga-specific-component-connections

* cleanup

* use-the-same-name

* add-lite-mode-remove-api-flag-and-mode

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

* public-or-private-internet

* agent-doesnt-check-urls

* peer-review

---------

Co-authored-by: April I. Murphy <[email protected]>

* docs: remove docling vlm component from 1.7 release branch (#10630)

remove-vlm-component

* docs: rename component categories and make all components single pages (#10648)

* docs: OpenAPI spec version upgraded from 1.6.5 to 1.6.8 (#10627)

Co-authored-by: github-merge-queue <[email protected]>
Co-authored-by: Mendon Kissling <[email protected]>

* up to models and agents

* sidebars

* fix-broken-links

* chore: Fix indentation on bundles-docling.mdx (#10640)

* sidebars

* redo-intros

* link-to-models

* data-components

* files-components-no-kb

* io-components

* helper-utility-components

* llm-ops-components

* logic-components

* processing-pages

* sidebars

* combine-legacy-components-into-one-page

* update-links

* remove-overview-pages-and-redirect

* make-mcp-tools-page

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

* no-cap

---------

Co-authored-by: Hanzo Dev <[email protected]>
Co-authored-by: github-merge-queue <[email protected]>
Co-authored-by: April I. Murphy <[email protected]>

* docs: combined web search component (#10664)

* combine-pages

* remove-rss-and-news-search-and-update-links

* remove-vlm-link

* leave-old-release-note-but-remove-link

* docs: add altk reflection component (#10660)

* add-new-component

* differentiate-components

* docs: mcp streamable http client (#10621)

* release note

* mcp-client-changes

* update-astra-example

* icons-and-copy

* order-of-names

* docs: add cuga decomposition strategy as advanced parameter (#10672)

* update-component-link

* init

* add-decomp-as-advanced-param

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

* update-component-index

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

---------

Co-authored-by: Hanzo Dev <[email protected]>
Co-authored-by: April I. Murphy <[email protected]>

* docs: datastax bundles page (#10686)

* init

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

---------

Co-authored-by: April I. Murphy <[email protected]>

* docs: llm router changed to llm selector (#10663)

* update-component-name

* previous-name-and-release-note

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

* docs: log alembic to stdout (#10711)

* docs-alembic-log-env-var

* cleanup

* remove-legacy-component-link

* docs: configure s3 for file storage backend (#10678)

* configure-file-storage-s3

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

* clarify-s3-credentials

* add-storage-tags-and-cleanup-creds-seciton

* role-link-name

* fix-parse-error

---------

Co-authored-by: April I. Murphy <[email protected]>

* docs: allow rest tweaks to mcp tools component (#10833)

* typo

* tweak-mcp-tools-component

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

---------

Co-authored-by: April I. Murphy <[email protected]>

* add-release-note

* docs: use mustache templates in prompts (#11262)

* mustache-templating

* syntax

* release-note

* peer-review

* docs: smart transform supports Message type  (#11306)

* component-supports-message-type

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

* peer-review

---------

Co-authored-by: April I. Murphy <[email protected]>

* docs: modular dependency imports for langflow-base (#11250)

* modular-base-dependencies

* syntax-and-clarification

* release-note

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

* [autofix.ci] apply automated fixes

* clarify-base-and-langflow

* component-index

* delete-component-index

* [autofix.ci] apply automated fixes

* set-agentic-experience

* potential-breaking-changes

* not-audio-package

* cleanup-and-syntax

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

---------

Co-authored-by: April I. Murphy <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>

* docs: symmetric and asymmetric JWT (#11159)

* initial-content

* cleanup

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

* [autofix.ci] apply automated fixes

* docs-peer-review

* [autofix.ci] apply automated fixes

---------

Co-authored-by: April I. Murphy <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>

* docs: add markdown output to url component (#11336)

* add-markdown-output-format

* raw-content

* Apply suggestions from code review

* docs: Add global variable support for MCP server headers (#11397)

* add-global-var-in-mcp-headers

* revert-curl-syntax-change

* remove-duplicate-tab

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

* remove-code-block

* add-release-note

---------

Co-authored-by: April I. Murphy <[email protected]>

* Update docs/docs/Develop/install-custom-dependencies.mdx

* Update docs/docs/Develop/jwt-authentication.mdx

* docs: global model provider feature (#11231)

* initial-changes-to-model-providers

* add-icon-for-model-partial

* syntax

* adding-custom-language-model

* release-note

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

* peer-review

* use-anthropic-model-with-agent

* [autofix.ci] apply automated fixes

* design-changes

---------

Co-authored-by: April I. Murphy <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>

* mustache-limitations

* release-note-for-jwt

* docs: playground refactor and screenshots (#11639)

* screenshots

* new-playground-and-icon

* release-note

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

---------

Co-authored-by: April I. Murphy <[email protected]>

* docs: component inspection panel (#11675)

* docs-component-inspection-panel

* cleanup

* docs: add tool shortlisting and remove web_apps from CUGA component (#11669)

docs-add-shortlist-tools-and-remove-webapps-parameters

* fix-details-tab-error

* docs: workflow API draft build (#11323)

* delete-unused-yaml-file

* initial-content

* add-python-and-ts-to-example-requests

* separate-pages

* test-spec-presentation

* hide-async-and-make-workflows-plural

* fix-broken-link

* add-changes-to-async

* use-workflow-spec-from-sdk-build

* make-setup-partial

* add-fetch-script-for-openapi-spec

* update-workflows-spec

* remove-stream-for-now

* remove-reconnect-to-stream

* consolidate-pages

* remove-force-boolean

* [autofix.ci] apply automated fixes

* docs: add guardrails component (#11674)

* docs-add-guardrails-component

* cleanup

* example-and-heuristic-check

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

* [autofix.ci] apply automated fixes

* add-note-about-llm

* add-release-note

---------

Co-authored-by: April I. Murphy <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>

* docs: pass env var to run command and endpoint as header (#11447)

* pass-env-var-to-lfx

* add-env-var-passing-to-run-endpoint

* add-python-and-js-commands

* docs: responses api token usage tracking (#11564)

* initlal-content

* add-release-note

* changes-for-accessing-advanced-parameters

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* small-playground-changes

* [autofix.ci] apply automated fixes

* Revert "docs: OpenAPI spec content updated without version change (#11787)"

This reverts commit e2f1d8db4c.

* [autofix.ci] apply automated fixes

* docs: add LiteLLM proxy bundle (#11867)

* docs-add-litellm-proxy-component

* Update docs/docs/Components/bundles-lite-llm.mdx

* docs: 1.8 changes from QA (#11998)

* remove-rightside-playground

* tutorials

* image-size-update

* component-release-notes

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

---------

Co-authored-by: April I. Murphy <[email protected]>

* docs: pass API keys to args and not env (#11997)

* remove-rightside-playground

* tutorials

* image-size-update

* docs-troubleshoot-mcp-proxy-header-keys

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

---------

Co-authored-by: April I. Murphy <[email protected]>

* docs: knowledge bases (#11924)

* docs-add-back-kb-content

* update-with-release-candidate-branch

* fix-linking-error

* remove-advanced-flag

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

* add-release-note

---------

Co-authored-by: April I. Murphy <[email protected]>

* docs: traces v0 (#12014)

* env-var-release-note-and-sidebars

* traces-and-database

* traces-ui-and-api-retrieval

* cleanup

* space

* move-section

* move-what-traces-capture-section

* docs: remove kb ingestion and rename kb retrieval (#12065)

remove-knowledge-ingestion-and-rename-knowledge-retrieval

* docs: add link to secret key rotation script (#12072)

* add-link-to-secret-key-rotation

* Apply suggestions from code review

Co-authored-by: April I. Murphy <[email protected]>

---------

Co-authored-by: April I. Murphy <[email protected]>

* docs: openlayer follow-on (#12073)

* add-openlayer-to-sidebars-and-release-notes

* Update docs/docs/Support/release-notes.mdx

---------

Co-authored-by: April M <[email protected]>
Co-authored-by: Edwin Jose <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
Co-authored-by: github-merge-queue <[email protected]>
Co-authored-by: Hanzo Dev <[email protected]>
2026-03-06 14:41:10 +00:00

95 lines
5.7 KiB
Plaintext

---
title: If-Else
slug: /if-else
---
import Icon from "@site/src/components/icon";
import PartialParams from '@site/docs/_partial-hidden-params.mdx';
The **If-Else** component is a conditional router that routes messages by comparing two strings.
It evaluates a condition by comparing two text inputs using the specified operator, and then routes the message to `true_result` or `false_result` depending on the evaluation.
The operator looks for single strings in the input (`input_text`) based on an operator and match text (`match_text`), but it can also search for multiple words by matching a regex.
Available operators include:
- **equals**: Exact match comparison
- **not equals**: Inverse of exact match
- **contains**: Checks if the `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**: Matches on a case-sensitive pattern
By default, all operators are case insensitive except **regex**.
**regex** is always case sensitive, and you can enable case sensitivity for all other operators in the [If-Else parameters](#if-else-parameters).
## Use the If-Else component in a flow
The following example uses the **If-Else** component to check incoming chat messages with regex matching, and then output a different response depending on whether the match evaluated to true or false.
![A conditional router connected to two OpenAI components](/img/component-conditional-router.png)
1. Add an **If-Else** component to your flow, and then configure it as follows:
* **Text Input**: Connect the **Text Input** port to a **Chat Input** component or another `Message` input.
If your input isn't in `Message` format, you can use another component to transform it, such as the [**Type Convert** component](/type-convert) or [**Parser** component](/parser).
If your input isn't appropriate for `Message` format, consider using another component for conditional routing, such as the [**Data Operations** component](/data-operations).
* **Match Text**: Enter `.*(urgent|warning|caution).*` so the component looks for these values in incoming input. The regex match is case sensitive, so if you need to look for all permutations of `warning`, enter `warning|Warning|WARNING`.
* **Operator**: Select **regex**.
* **Case True**: In the [component inspection panel](/concepts-components#component-menus), enable the **Case True** parameter, click **Close**, and then enter `New Message Detected` in the field.
The **Case True** message is sent from the **True** output port when the match condition evaluates to true.
No message is set for **Case False** so the component doesn't emit a message when the condition evaluates to false.
3. Depending on what you want to happen when the outcome is **True**, add components to your flow to execute that logic:
1. Add a **Language Model**, **Prompt Template**, and **Chat Output** component to your flow.
2. In the **Language Model** component, enter your OpenAI API key or select a different provider and model.
3. Connect the **If-Else** component's **True** output port to the **Language Model** component's **Input** port.
4. In the **Prompt Template** component, enter instructions for the model when the evaluation is true, such as `Send a message that a new warning, caution, or urgent message was received`.
5. Connect the **Prompt Template** component to the **Language Model** component's **System Message** port.
6. Connect the **Language Model** component's output to the **Chat Output** component.
4. Repeat the same process with another set of **Language Model**, **Prompt Template**, and **Chat Output** components for the **False** outcome.
Connect the **If-Else** component's **False** output port to the second **Language Model** component's **Input** port.
In the second **Prompt Template**, enter instructions for the model when the evaluation is false, such as `Send a message that a new low-priority message was received`.
5. To test the flow, open the **Playground**, and then send the flow some messages with and without your regex strings.
The chat output should reflect the instructions in your prompts based on the regex evaluation.
```text
User: A new user was created.
AI: A new low-priority message was received.
User: Sign-in warning: new user locked out.
AI: A new warning, caution, or urgent message was received. Please review it at your earliest convenience.
```
## If-Else parameters
<PartialParams />
| Name | Type | Description |
|----------------|----------|-------------------------------------------------------------------|
| input_text | String | Input parameter. The primary text input for the operation. |
| match_text | String | Input parameter. The text to compare against. |
| operator | Dropdown | Input parameter. The operator used to compare texts. Options include `equals`, `not equals`, `contains`, `starts with`, `ends with`, and `regex`. The default is `equals`. |
| case_sensitive | Boolean | Input parameter. When `true`, the comparison is case sensitive. The default is `false`. This setting doesn't apply to regex comparisons. |
| max_iterations | Integer | Input parameter. The maximum number of iterations allowed for the conditional router. The default is 10. |
| default_route | Dropdown | Input parameter. The route to take when max iterations are reached. Options include `true_result` or `false_result`. The default is `false_result`. |
| true_result | Message | Output parameter. The output produced when the condition is true. |
| false_result | Message | Output parameter. The output produced when the condition is false. |