Saltar al contenido principal

Branch

Nodo de flujobranchlogic

Splits the run into paths. The first path whose condition holds runs; otherwise the "otherwise" path, if there is one.

De un vistazo​

PropiedadValor
Node fieldbranch (set instead of stepRef on a FlowNode)
Side effectsno

A FlowNode sets exactly one of stepRef, branch, filter, forEach, wait and approval.

The value is a list; each item has the settings below.

Conditions use the expression language: a field, an operator and a value, as in {field: details.total, op: gte, value: 10000}.

Ajustes​

El valor del campo del nodo, con estos ajustes.

AjusteTipoValor por defectoDescripción
whenobject-When is the case's condition. It may be left out while the case is not set up yet: the webhook then reports the Flow incomplete, so it can be saved suspended as a draft. When present, its field is strict.
when.exprstring-Expr is the condition as text. Every field in it is a node or trigger upstream on every path to this one, and one of its outputs.
when.fieldstring-Field is <nodeId>.<field>: a node or trigger upstream on every path to this one, and one of its outputs.
when.opstring-
nextobligatoriolist of string-

El JSON Schema completo de estos ajustes: branch.schema.json.

Úsalo en un flujo​

flow.yaml
apiVersion: lumen.ai/v1alpha1
kind: Connector
metadata:
name: my-email-forward
namespace: tenant-acme
spec:
classRef: {name: email-forward}
config: {}
---
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
name: branch-example
namespace: tenant-acme
spec:
displayName: "Branch"
triggers:
- id: start
ref: {name: email-arrives}
connectorRef: {name: my-email-forward}
next: [text]
nodes:
- id: text
stepRef: {name: read-text}
next: [details]
- id: details
stepRef: {name: chat-agent}
config:
instructions: Find the total in the invoice.
fields: [{name: total, type: money}]
files: {mode: ifNoText}
next: [route]
- id: route
branch:
- when: {field: details.total, op: gte, value: 10000}
next: [large]
branchDefault: [small]
- id: large
stepRef: {name: notify-in-app}
config:
to: admins
title: A large invoice came in
body: "Total: {details.total}"
- id: small
stepRef: {name: save-file}
config: {destination: lumen}