The Condition logic element in Optimizely Opal's workflow agent builder introduces decision-making and branching paths into your workflows. It uses "if this, then that" logic to evaluate a criterion, directing the workflow to different actions based on whether it meets that criterion. Your workflow agents adapt dynamically to varying data, user inputs, or system states, ensuring the correct process for every scenario.
When to use conditions
Conditions are essential when your workflow makes decisions and follows different paths based on specific criteria. Consider using a Condition in the following situations:
- Dynamic routing – Direct tasks or content to different teams, individuals, or stages based on their attributes, such as content type, priority, or associated campaign.
- Conditional execution – Perform an action only if certain prerequisites apply. For example, send a notification if a deadline approaches, or publish content if you approve it.
- Data validation – Check if inputs or data points meet specific requirements before letting the workflow proceed. For example, ensure a budget value is within an acceptable range.
How to add a condition to a workflow
After following the steps to create a workflow agent from scratch and configure workflow, optionally add conditions to your workflow.
- Drag and drop a Condition from the Logic section into the workspace.
- Drag and drop two agents from the Agents section into the workspace.
-
Connect the Condition to an Agent before and after it. Click the Condition and click a connector circle. Drag the connector to the Agent.
- Select a Match Type. Options include the following:
- Equals – The output matches the condition value exactly.
- Not Equals – The output does not match the condition value.
- Contains – The output contains the condition value.
- Not Contains – The output does not contain the condition value.
- Greater Than – The output is greater than the condition value.
- Less Than – The output is less than the condition value.
- Greater Than or Equals – The output is greater than or equal to the condition value.
- Less Than or Equals – The output is less than or equal to the condition value.
- Regex – The output matches a regular expression pattern.
-
Enter a Condition. This is what you are checking for.
- (Optional) Continue building your workflow. You can add more agents and connect the Condition to them to for other outcomes.
- Click Save to update your workflow agent.
Best practices and considerations
Keep the following in mind when working with Condition logic elements:
- Clarity of criteria – Use precise and unambiguous criteria in your conditions.
- Exhaustive paths – Account for both the "true" and "false" (or "else") paths of a condition. If you do not handle a path, a workflow can stall or behave unpredictably.
- Data availability – Confirm that the required data is within the workflow's context and is in the correct format for the Condition to evaluate. Data typically comes from the outputs of previous agents or system variables.
- Manage complexity – Avoid creating overly complex single conditions. For intricate decision trees, consider breaking down the logic into a series of simpler, sequential conditions or nesting them appropriately.
- Nesting – Nest conditions within loops, letting you create sophisticated and highly adaptive workflow logic.
Example: conditional content approval
Example scenario – Your content marketing team uses workflow agents to manage the approval process for new articles. "High Priority" articles require an additional review step by a senior editor, while standard articles proceed to a regular editor.
You can create a workflow agent that uses a Condition to automate this routing.
- Start – The workflow agent begins after you submit a new article draft in Optimizely Content Marketing Platform (CMP).
-
Get article details – The workflow agent retrieves the details of the new article you submitted, including its priority level.
-
Specialized agent and tools used – Use a specialized agent that uses the
get_cmp_resourceOpal tool for CMP to get the article and its details. -
Output – See article details, including a
priorityattribute. For example,"High","Medium", or"Low".
-
Specialized agent and tools used – Use a specialized agent that uses the
-
Condition logic – This Condition evaluates the
priorityof the article.-
Criterion –
Equals "High".- Action – Assign the article to a Senior Editor for review.
-
Specialized agent and tools used – Use a specialized agent that uses the
update_tasktool for CMP to assign the article to a Senior Editor. - Configuration – Set the assignee to "Senior Editor Team" or a specific senior editor.
-
Criterion –
Not Equals "High"- Action – Assign the article to a Standard Editor for review.
-
Specialized agent and tools used – Use a specialized agent that uses the
update_tasktool for CMP to assign the article to the Standard Editor Team - Configuration – Set the assignee to "Standard Editor Team" or a specific standard editor.
-
Criterion –
- End – The workflow continues, and the workflow now assigns the article to the appropriate editor for review based on its priority.
This example shows how a Condition lets a workflow agent make an intelligent decision, ensuring that content follows the correct approval path without manual intervention.
Article is closed for comments.