Switch

A guide on using the Switch action to create multiple conditional branches in your workflow.

The Switch Action is an advanced control flow tool that allows you to route your workflow down multiple different paths based on the value of a single input. It's like a series of "If/Else If/Else" statements rolled into one, making it perfect for handling situations where you have more than two possible outcomes.

Use the Switch Action when you need to take different actions based on a specific category, status, or type.

How it Works

The Switch Action evaluates an Input Value and compares it against a list of possible Cases you define. The workflow then follows the path of the first case that matches. If no cases match, it will follow a special Default path.

graph TD
    A[Start] --> B{Switch on ticket_category};
    B --> |"Billing"| C[Route to Billing Team];
    B --> |"Technical"| D[Route to Tech Support];
    B --> |"Sales"| E[Route to Sales Team];
    B --> |"Other"| F[Default: Create General Inquiry];

Configuration

You configure the action by defining the input to check and the cases to match against.

Input Parameters

Parameter
Type
Description

Input Value

Text

The data you want to evaluate. This is typically a variable from a previous action (e.g., {{llm_action.output}}).

Cases

For each potential branch, you add a Case:

  • Condition: The type of comparison to perform (e.g., equals, contains, starts with).

  • Target Value: The value that the Input Value must match for this case to be selected.

The Switch action will have an output connection for each case you define, plus one for the default case.

Example: Routing Support Tickets

Imagine an LLM action categorizes incoming support emails into one of three types: Billing, Technical, or Sales. You can use a Switch action to route them appropriately.

  • Input Value: {{llm_action.category}}

  • Case 1:

    • Condition: equals

    • Target Value: Billing

    • (Connect this path to an action that alerts the finance team)

  • Case 2:

    • Condition: equals

    • Target Value: Technical

    • (Connect this path to an action that creates a ticket in Jira)

  • Case 3:

    • Condition: equals

    • Target Value: Sales

    • (Connect this path to an action that adds a lead to your CRM)

  • Default Path:

    • (Connect this path to an action that sends a generic "We'll get back to you soon" email)

Last updated

Was this helpful?