Sim Studio

Router

Route workflow execution based on specific conditions or logic

The Router block is a powerful component in Sim Studio that intelligently routes workflow execution based on content analysis, user input, or predefined conditions. It acts as a decision-making junction in your workflow, directing the flow to different paths based on various criteria.

Overview

The Router block uses LLMs to analyze input content and determine the most appropriate next step in your workflow. This allows for:

  • Creating dynamic, adaptable workflows
  • Implementing complex decision trees
  • Routing user requests to specialized components
  • Building conversational systems that can handle diverse inputs

How It Works

The Router block:

  1. Analyzes the input content using an LLM
  2. Evaluates the content against the available target blocks in your workflow
  3. Identifies the most appropriate destination based on the content's intent or requirements
  4. Routes the workflow execution to the selected block

Configuration Options

Content/Prompt

The content or prompt that the Router will analyze to make routing decisions. This can be:

  • A direct user query or input
  • Output from a previous block
  • A system-generated message

Target Blocks

The possible destination blocks that the Router can select from. The Router will automatically detect connected blocks, but you can also:

  • Customize the descriptions of target blocks to improve routing accuracy
  • Specify routing criteria for each target block
  • Exclude certain blocks from being considered as routing targets

Model Selection

Choose an LLM provider to power the routing decision:

  • OpenAI (GPT-4o, o1, o3-mini)
  • Anthropic (Claude 3.7 Sonnet)
  • Google (Gemini 2.5 Pro, Gemini 2.0 Flash)
  • Groq, Cerebras
  • Ollama Local Models
  • And more

Select a model with strong reasoning capabilities for more accurate routing decisions.

API Key

Your API key for the selected LLM provider. This is securely stored and used for authentication.

Inputs and Outputs

Inputs

  • Content/Prompt: The text to analyze for routing decisions
  • Target Blocks: Connected blocks that are potential routing destinations
  • Model Settings: LLM provider and parameters

Outputs

  • Content: A summary of the routing decision
  • Model: The model used for decision-making
  • Tokens: Usage statistics
  • Selected Path: Details of the chosen routing destination, including:
    • Block ID
    • Block Type
    • Block Title

Example Usage

Here's an example of how a Router block might be used in a customer support workflow:

# Example Router Configuration
prompt: |
  Analyze the user query and route to the most appropriate department.
  Choose ONE destination based on the query content and intent.
 
model: OpenAI/gpt-4

In this example, the Router might be connected to:

  • A product support block
  • A billing inquiries block
  • A technical support block
  • A general inquiries block

Based on the user's query, the Router would analyze the content and direct it to the most appropriate specialized support block.

Best Practices

  • Provide clear descriptions for target blocks: Help the Router understand when to select each destination
  • Use specific routing criteria: Define clear conditions for selecting each path
  • Consider fallback paths: Connect a default destination for when no specific path is appropriate
  • Test with diverse inputs: Ensure the Router handles various input types correctly
  • Review routing decisions: Monitor the Router's performance and refine as needed
On this page

On this page