flow.if

Conditionally execute one action or another. The if component is the most
common component used for branching a flow (this is very similar to an
if statement in a convention programming language like Python).

- if: (@ user.age > 18 )
  then: next
  else:
    flow: flow.confirm_age

In this example the component is checking if the user's age above 18, and
if so, then it will proceed to the next step, otherwise it will call a
nested flow named flow.confirm_age (check the nested flows guide for
more detail on how nested flows work).

Evaluation criteria

The if field contains the evaluation criteria which needs to evaluate to
either true or false. For example, we can set the value to true which
will result in the then component always being run:

- if: true
  then: next
  else: end

Conversely, when the if field is set to false, the else component
will always be run.

Setting if to either true/false is not very useful, but when we use the
Meya template syntax, we can
create complex evaluation criteria using a combination of template operators
and flow/thread/user scope variables.

then/else components

Both the then and else fields are action fields, meaning the field
takes an action spec which maps to the ActionComponentSpec
Python class. This allows you to define and execute any component, but
mostly you will use one of the flow control components such as:

Element details

type: meya.flow.component.if
class: IfComponent
path: /meya/flow/component/if_.py
signature: if

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
ifContains the evaluation criteria which is expressed using Meya's template syntax.typing.Any
thenContains the action component reference that is called when the evaluation criteria is True.ActionComponentSpec
elseContains the action component reference that is called when the evaluation criteria is False.ActionComponentSpec

Usage reference

Basic

triggers:
  - keyword: meya.flow.component.if
steps:
  - if: ANY
    then: COMPONENT
    else: COMPONENT

Full

triggers:
  - keyword: meya.flow.component.if
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
    if: ANY
    then: COMPONENT
    else: COMPONENT