Switch Case¶
Class: SwitchCaseBlockV1
Source: inference.core.workflows.core_steps.flow_control.switch_case.v1.SwitchCaseBlockV1
Route workflow execution to one of several branches by matching an input value against a set of case values, similar to a switch-case statement in programming, enabling multi-way branching, value-based routing, and decision trees without chaining multiple Continue If blocks.
How This Block Works¶
This block compares a single input value against the keys of a case mapping and directs execution to the step associated with the first matching case. The block:
- Takes a
valueinput (typically a selector referencing a workflow input or a step output, e.g. a classification result) and converts it to a string - Looks the string up in the
casesmapping, where each key is a case value and each value is the step to execute when that case matches (e.g.{"red": "$steps.on_red", "blue": "$steps.on_blue"}) - If
case_insensitiveis enabled, the comparison ignores letter case - If a case matches, execution continues to that case's step and all other branches terminate
- If no case matches, execution continues to the steps listed in
default_next_steps - If no case matches and
default_next_stepsis empty, the branch terminates
Because the input value is converted to a string before matching, non-string values match their
string representation: True matches the key "True", 1.0 matches "1.0" (not "1"), and a
missing/None value matches "None". Each target step may appear at most once across cases and
default_next_steps — to route several case values to the same logic, point each case at its own
step or normalize the value upstream (e.g. with an Expression block).
Common Use Cases¶
- Routing by classification result: Send images down different processing paths based on the top class predicted by a classification model (e.g. "damaged" → alert branch, "ok" → logging branch, anything else → default review branch)
- Mode-based pipelines: Use a workflow input parameter (e.g.
$inputs.mode) to select between alternative processing branches at runtime without editing the workflow - Multi-way alerting: Route to different notification blocks (email, Slack, webhook) depending on a severity or category value computed earlier in the workflow
- Replacing chained conditions: Collapse a ladder of Continue If blocks comparing the same value against different constants into a single, easier-to-read block
Connecting to Other Blocks¶
This block controls workflow execution flow and can be connected:
- After classification or detection blocks to branch on predicted classes, counts, or other prediction properties (often via a Property Definition or Expression block that extracts the value to switch on)
- After workflow inputs to select a branch from a runtime parameter
- Before any downstream blocks (models, notifications, sinks) that should only run for a specific case — each case target becomes the head of its own execution branch
- With a default branch wired via
default_next_stepsto handle unmatched values, or left empty to simply stop when nothing matches
Type identifier¶
Use the following identifier in step "type" field: roboflow_core/switch_case@v1to add the block as
as step in your workflow.
Properties¶
| Name | Type | Description | Refs |
|---|---|---|---|
name |
str |
Enter a unique identifier for this step.. | ❌ |
value |
Union[bool, float, int, str] |
Value to match against the case keys. Typically a selector referencing a workflow input or a step output (e.g. $inputs.mode or $steps.classifier.top). The value is converted to a string before comparison, so booleans match keys 'True'/'False', 1.0 matches '1.0' and a None value matches 'None'.. | ✅ |
case_insensitive |
bool |
When enabled, case values are matched ignoring letter case (e.g. value 'RED' matches case key 'red').. | ❌ |
The Refs column marks possibility to parametrise the property with dynamic values available
in workflow runtime. See Bindings for more info.
Available Connections¶
Compatible Blocks
Check what blocks you can connect to Switch Case in version v1.
- inputs:
Detections Filter,Absolute Static Crop,VLM As Classifier,Qwen-VL,Gaze Detection,Cache Get,Byte Tracker,Triangle Visualization,EasyOCR,Model Comparison Visualization,Detection Event Log,Stitch OCR Detections,Track Class Lock,YOLO-World Model,OC-SORT Tracker,Llama 3.2 Vision,Anthropic Claude,Heatmap Visualization,Stitch Images,Keypoint Visualization,Webhook Sink,Detections Stabilizer,Continue If,Dominant Color,Google Gemini,MoonshotAI Kimi,GLM-OCR,Instance Segmentation Model,VLM As Detector,QR Code Generator,SAM2 Video Tracker,Multi-Label Classification Model,Twilio SMS/MMS Notification,Line Counter,PLC ModbusTCP,Distance Measurement,Ellipse Visualization,Single-Label Classification Model,SmolVLM2,Keypoint Detection Model,Pixelate Visualization,Detections Transformation,Corner Visualization,Overlap Analysis,Rate Limiter,Switch Case,Buffer,Bounding Rectangle,Template Matching,Llama 3.2 Vision,Qwen2.5-VL,JSON Parser,Qwen 3.5 API,Per-Class Confidence Filter,LMM,Inner Workflow,Velocity,Roboflow Visual Search,Semantic Segmentation Model,OpenAI-Compatible LLM,Morphological Transformation,Color Visualization,Roboflow Dataset Upload,Dimension Collapse,Morphological Transformation,Camera Calibration,Motion Detection,Detection Offset,Google Vision OCR,Clip Comparison,Bounding Box Visualization,OpenAI,Halo Visualization,SAM3 Video Tracker,Object Detection Model,Identify Changes,First Non Empty Or Default,Detections Combine,Contrast Equalization,CSV Formatter,Environment Secrets Store,Mask Area Measurement,Expression,Detections Classes Replacement,Instance Segmentation Model,Model Monitoring Inference Aggregator,Multi-Label Classification Model,MQTT Writer,Cache Set,Delta Filter,PLC Reader,Image Threshold,Blur Visualization,Line Counter Visualization,Google Gemini,Microsoft SQL Server Sink,Single-Label Classification Model,Background Subtraction,VLM As Classifier,Object Detection Model,Identify Outliers,Path Deviation,QR Code Detection,Polygon Zone Visualization,Instance Segmentation Model,SAM 3,Twilio SMS Notification,Google Gemma API,OPC UA Writer Sink,Keypoint Detection Model,Image Stack,Reference Path Visualization,SAM 3 Interactive,Qwen3-VL,Stability AI Inpainting,Multi-Label Classification Model,Perception Encoder Embedding Model,Crop Visualization,Anthropic Claude,Dynamic Zone,Image Convert Grayscale,Camera Focus,Image Slicer,Overlap Filter,Florence-2 Model,Polygon Visualization,Time in Zone,MoonshotAI Kimi,Dynamic Crop,Qwen 3.6 API,Event Writer,Perspective Correction,Segment Anything 2 Model,Line Counter,Polygon Visualization,Clip Comparison,OCR Model,Roboflow Visual Search Classifier,Circle Visualization,Slack Notification,CogVLM,Contrast Enhancement,PLC EthernetIP,Grid Visualization,Mask Edge Snap,Barcode Detection,Byte Tracker,LMM For Classification,Florence-2 Model,OpenAI,Time in Zone,Roboflow Custom Metadata,Local File Sink,SORT Tracker,Image Blur,Label Visualization,ByteTrack Tracker,Qwen3.5-VL,Seg Preview,Path Deviation,Object Detection Model,Anthropic Claude,Cosine Similarity,Pixel Color Count,Roboflow Vision Events,Image Preprocessing,Trace Visualization,Email Notification,SIFT Comparison,Stability AI Outpainting,Detections Consensus,PTZ Tracking (ONVIF),Current Time,Dot Visualization,Roboflow Asset Library Attributes,Keypoint Detection Model,Halo Visualization,SAM 3,Classification Label Visualization,Property Definition,Image Contours,Camera Focus,Single-Label Classification Model,OpenRouter,Data Aggregator,S3 Sink,Stability AI Image Generation,VLM As Detector,CLIP Embedding Model,Relative Static Crop,Roboflow Dataset Upload,Google Gemma,OpenAI,Moondream2,Image Slicer,Detections Merge,Stitch OCR Detections,Google Gemini,BoT-SORT Tracker,Email Notification,Byte Tracker,SAM 3,Detections Stitch,Text Display,Semantic Segmentation Model,Size Measurement,Qwen3.5,Depth Estimation,Icon Visualization,OpenAI,Time in Zone,GeoTag Detection,PLC Writer,SIFT Comparison,SIFT,Instance Segmentation Model,Background Color Visualization,Detections List Roll-Up,Mask Visualization - outputs: None
Input and Output Bindings¶
The available connections depend on its binding kinds. Check what binding kinds
Switch Case in version v1 has.
Bindings
-
input
value(*): Value to match against the case keys. Typically a selector referencing a workflow input or a step output (e.g. $inputs.mode or $steps.classifier.top). The value is converted to a string before comparison, so booleans match keys 'True'/'False', 1.0 matches '1.0' and a None value matches 'None'..cases(step): Mapping of case value to the step that should execute whenvaluematches it, e.g. {"red": "$steps.on_red", "blue": "$steps.on_blue"}. Each target step may appear at most once acrosscasesanddefault_next_steps..default_next_steps(step): Steps to execute when no case matches. Leave empty to terminate the branch when nothing matches..
-
output
Example JSON definition of step Switch Case in version v1
{
"name": "<your_step_name_here>",
"type": "roboflow_core/switch_case@v1",
"value": "$steps.classifier.top",
"cases": {
"blue": "$steps.on_blue",
"red": "$steps.on_red"
},
"case_insensitive": false,
"default_next_steps": [
"$steps.fallback"
]
}