Skip to main content

If{{expression}} else Brick

PurposeLearn about the various configurations and parameters required for the If{{expression}} else Brick to function correctly.
Last updatedAugust 05, 2024

What is the If{{expression}} else (Operator Brick)?

This Brick, designed for decision-making, helps determine actions based on specific conditions. For example, it directs what to do depending on whether data meets certain criteria, ensuring different paths or actions for different situations.

Use the branch at the bottom when the command matches if; otherwise, use the branch on the right when the command matches else.


If{{expression}} else Brick Parameters

  1. Label: This is where the user can provide a name for the brick.

  2. Expression: In Vector Remap Language (VRL), define the value that needs matching with the data passing through this brick. If the match holds true, it follows one path; if not, it proceeds along a different path.

    • Example

      • string!(%data.value) == "success"
      `string!(%data.value)`: Converts `%data.value` into a string for comparison.
      `== "success"`: Checks if the string representation of `%data.value` equals `"success"`.

      In this example:
      `%data.value` represents some variable or data attribute.
      The expression checks if `%data.value` is equal to `"success"` after converting it into a string.
      This can be used in conditional statements or expressions to control the flow of logic based on the value of `%data.value`.

For more information and syntax, please follow the link below:

Learn more about VRL


If{{expression}} else Brick output format

In this section of the documentation the user will learn where are the outputs of the brick stored and its format.

The output variables may vary depending on the input brick providing the data, here are some examples:

  1. Name of variable: python
    • Format:
      • data (dictionary): data prepared for transmission to the topic
      • contextInfo (Dictionary): Contains information about the context of the conversation.
      • direction (String): Indicates the direction of the message, e.g., "received".
      • from (Dictionary): Contains details about the sender of the message.
      • message (Dictionary): Contains details about the message.
      • timestamp (Integer): The timestamp of the message.
      • to (String): The unique identifier (JID) of the recipient.
      • type (String): Indicates the type of the outer structure, e.g., "message".
      • version (Integer): The version of the message structure.