flow.cond

Specify multiple evaluation criteria and run an action if the criteria
evaluates to true.

- cond:
   - (@ user.age < 18):
       flow: flow.confirm_age
   - (@ user.age >= 18 and user.age < 65 ):
       jump: next
   - (@ user.age >= 65):
       flow: flow.retired
  default: next

Similar to the flow.if component's
if field, the evaluation criteria must evaluate to either true
or false, and thus we can use Meya template syntax to
create complex evaluation criteria using a combination of template operators
and flow/thread/user scope variables.

Also, each condition in the cond field must contain a valid action field,
meaning the field takes an action spec which maps to the ActionComponentSpec
Python class. This allows you to execute any component, but you will mostly
use one of the flow control components.

Element details

type: meya.flow.component.cond
class: CondComponent
path: /meya/flow/component/cond.py
signature: cond

Fields

fielddescription               requiredsignaturedefaulttype
specOverride the original spec for this element.nullSpec
contextSend context data with this component's event.{}
dict
sensitiveMark this component's event as sensitive. This will encrypt the event if the Sensitive Data integration has been enabled.falsebool
triggersActivate these dynamic triggers when the component runs. Check the component triggers guide for more info.[]list
condContains a set of evaluation criteria that will be evaluated in order starting with the first evaluation criteria. The evaluation criteria is expressed using Meya's template syntax.list
defaultThis is the default action should none of the evaluation criteria evaluate to True.ActionComponentSpec

Usage reference

Basic

triggers:
  - keyword: meya.flow.component.cond
steps:
  - cond:
      - ANY: COMPONENT
    default: COMPONENT

Full

triggers:
  - keyword: meya.flow.component.cond
steps:
  - spec:
      type: STRING
      data:
        STRING: ANY
      timeout: 123
      trigger_when: ANY
    context:
      STRING: ANY
    sensitive: false
    triggers:
      - type: STRING
        data:
          STRING: ANY
        timeout: 123
        trigger_when: ANY
    cond:
      - ANY: COMPONENT
    default: COMPONENT