Workflow agent conditions

  • Updated

Use the Condition logic element in the Optimizely Opal workflow agent builder to add decision-making and branching to your workflows. A Condition evaluate a criterion and routes the workflow to different actions depending on the result, so your agents respond correctly to different data, user inputs, or system states without requiring manual intervention.

The following shows the Condition element in the Logic section in the workflow agent builder UI.

Screenshot of the Optimizely Opal workflow agent builde showing a trigger and agent and a Condition highlighted

When to use conditions

Conditions are useful when your workflow makes decisions and follows different paths based on specific criteria. Use 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 you create a workflow agent and configure it, add conditions as needed.

  1. Drag and drop a Condition from the Logic section into the workspace.
  2. Click the condition's connector circle. 
  3. Drag the connector to an Agent
  4. Click the Condition.
  5. Click Add Condition.

    Screenshot of the Condition panel in Optimizely Opal where the Add Condition button is highlighted
  6. 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.
  7. Enter the value you want the Condition to check for.
  8. (Optional) Select Match case if you want the Condition to be case-sensitive.

    Screenshot of the Condition configuration panel showing the Condition options
  9. Drag and drop the next agent into the Drag and drop step section.

    Screenshot of the Condition panel showing the Drag and drop step section where the next agent is dropped
  10. (Optional) Continue building your workflow. 
    1. Click Add Condition.
    2. Repeat steps 6–9 for other outcomes.
    3. Add agents and other conditions, such as Loops.
  11. 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 available in the workflow's context and formatted correctly 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 Condition elements within Loop elements to handle repeating decision logic. For example, evaluate a condition on each item in a list as the loop iterates.

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.

Create a workflow agent that uses a Condition to automate this routing.

  1. Start – The workflow agent begins after you submit a new article draft in Optimizely Content Marketing Platform (CMP).
  2. 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_resource Opal tool for CMP to get the article and its details.
    • Output – See article details, including a priority attribute. For example, "High", "Medium", or "Low".
  3. Condition logic – This Condition evaluates the priority of the article.
    • CriterionEquals "High" with Match case checked.
      • Action – Assign the article to a Senior Editor for review.
      • Specialized agent and tools used – Use a specialized agent that uses the update_task tool for CMP to assign the article to a Senior Editor.
      • Configuration – Set the assignee to "Senior Editor Team" or a specific senior editor.
    • CriterionNot Equals "High" with Match case checked.
      • Action – Assign the article to a Standard Editor for review.
      • Specialized agent and tools used – Use a specialized agent that uses the update_task tool for CMP to assign the article to the Standard Editor Team.
      • Configuration – Set the assignee to "Standard Editor Team" or a specific standard editor.
  4. End – The workflow continues and assigns the article to the appropriate editor for review based on its priority.
Diagram of a workflow agent showing a Condition element routing high-priority articles to a Senior Editor and all other articles to a Standard Editor

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.