Working with conditions

Learn how conditions function, how to set them up between two actions, and how to use built-in conditional operators effectively.

About this task

Set up conditions between two conditions (or between a trigger and a condition) in a workflow. If the conditions are met, the workflow proceeds to the next action. If the conditions fail, the workflow stops. When defining conditions, specify an input, a condition, and an expected value. The input that you use in a condition is usually the output of the preceding condition or trigger.

For example, consider the following condition in a workflow.
  • Input - {{$a1.translated_text}}
  • Condition - contains
  • Expected - hola

Here, {{$a1.translated_text}} is the output of the preceding condition, contains is the operator, and hola is the expected value. If you set this condition, the workflow proceeds to the next action only if the output text of the previous action contains the word hola in it.

Learn how you can apply a condition to a practical scenario. Imagine you want to automatically send card details to a specific Slack channel whenever a new card with the name approval required is added to a specific list in Trello.

Procedure

  1. Configure the Trello - New Note trigger.
  2. Add Slack to the canvas. You notice that it gets automatically connected to the Start icon (which now has the Trello trigger icon). Next, connect the Slack connector to the Stop icon to complete your workflow.
  3. Double-click the Slack connector icon, select Post Message to Channel from the Select Action drop-down list, and select the Slack account that you want to use to run the action. After completing this step, click Next.
  4. Select or add the Trello account that you want to use to run the trigger.
    • Board ID - Select or specify the ID of the board for which you want to set the trigger.
    • List ID - Select or specify the ID of the list for which you want to set the trigger.

      Next, click Save, test the trigger, and return to the canvas.

  5. In the action configuration form that appears, enter the following details.
    • Select Channel Type - Select the type of channel to which you want to send card details.
    • Channel ID or Channel Name - Select or specify the ID or name of the channel to which you want to send notifications.
    • Text - As the card details need to be sent, add the action object that is listed under Trigger Data - New Card.

      Click Next, test the action, and return to the canvas.

  6. Add conditional logic to the workflow. To do so, click the connecting line between the trigger and action, and select Settings.
  7. Click Add Condition listed under Condition Activity. A new condition block appears with an option Add Filter.
  8. Click Add Filter to set a new filter condition. You are redirected to the Condition page where you can see the incoming data on the left side and the condition block on the right. Here, you can define the input, the condition, and the expected value.
    • Input - Drag or enter the input value on which you want to set a condition. Drag the card_name key, which contains the card title, and listed under Trigger Data - New Card into the Input field.
    • Condition - Select the condition that you want to set on the specified input.
    • Expected - Enter the value to match against the specified input and condition. Enter approval required to check whether the input contains this phrase.
  9. Now that the condition is set, go back to the canvas and save the workflow.
  10. Now, whenever a new card is created in Trello in the list, webMethods Integration automatically checks whether the card name contains the words approval required, and if it does, sends the card details to the specified Slack channel.