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:
Keypoint Visualization,Keypoint Detection Model,Twilio SMS/MMS Notification,OPC UA Writer Sink,Perception Encoder Embedding Model,Qwen 3.6 API,SIFT Comparison,Grid Visualization,SAM 3,Object Detection Model,Llama 3.2 Vision,PLC Writer,JSON Parser,Absolute Static Crop,Distance Measurement,Roboflow Visual Search Classifier,Velocity,Image Threshold,Polygon Zone Visualization,CogVLM,BoT-SORT Tracker,MQTT Writer,Contrast Equalization,Google Gemini,Detections List Roll-Up,OCR Model,GLM-OCR,Background Subtraction,Contrast Enhancement,Reference Path Visualization,Twilio SMS Notification,Instance Segmentation Model,Google Gemma API,Mask Edge Snap,Detections Filter,Detections Classes Replacement,Detections Merge,PTZ Tracking (ONVIF),VLM As Detector,Florence-2 Model,Dynamic Crop,Halo Visualization,Image Blur,LMM,SAM 3 Interactive,Seg Preview,SAM 3,Ellipse Visualization,OpenAI,Byte Tracker,Florence-2 Model,Line Counter,LMM For Classification,Time in Zone,Cache Set,Path Deviation,OpenAI,Data Aggregator,Instance Segmentation Model,Semantic Segmentation Model,Event Writer,Time in Zone,Single-Label Classification Model,Keypoint Detection Model,Google Gemma,Byte Tracker,Buffer,Slack Notification,Heatmap Visualization,SORT Tracker,Semantic Segmentation Model,Email Notification,Circle Visualization,Perspective Correction,Camera Focus,Byte Tracker,Crop Visualization,Detections Consensus,Polygon Visualization,Keypoint Detection Model,Line Counter,ByteTrack Tracker,Multi-Label Classification Model,Detections Combine,Stability AI Inpainting,OpenAI-Compatible LLM,SAM 3,Object Detection Model,VLM As Classifier,PLC ModbusTCP,Google Gemini,Image Slicer,Roboflow Vision Events,Detections Transformation,Multi-Label Classification Model,Size Measurement,Qwen3.5,Local File Sink,Delta Filter,Object Detection Model,Inner Workflow,SAM3 Video Tracker,Dot Visualization,QR Code Detection,Line Counter Visualization,Expression,Depth Estimation,Time in Zone,Instance Segmentation Model,Stitch OCR Detections,PP-OCR,Blur Visualization,Clip Comparison,EasyOCR,Anthropic Claude,PLC EthernetIP,Segment Anything 2 Model,CSV Formatter,Color Visualization,Per-Class Confidence Filter,Qwen2.5-VL,Qwen3-VL,Dynamic Zone,Image Convert Grayscale,Motion Detection,Stitch OCR Detections,Rate Limiter,Single-Label Classification Model,Qwen 3.5 API,Current Time,Icon Visualization,Trace Visualization,Cache Get,PLC Reader,Model Comparison Visualization,Camera Focus,QR Code Generator,Google Gemini,Detections Stitch,Image Stack,Instance Segmentation Model,Qwen-VL,Mask Visualization,MoonshotAI Kimi,Microsoft SQL Server Sink,Text Display,Gaze Detection,Stability AI Image Generation,Continue If,Google Vision OCR,Webhook Sink,OpenAI,VLM As Detector,Identify Outliers,Cosine Similarity,Pixelate Visualization,Stitch Images,Detection Offset,Switch Case,Classification Label Visualization,S3 Sink,MoonshotAI Kimi,Polygon Visualization,Overlap Filter,Anthropic Claude,Dimension Collapse,Roboflow Dataset Upload,Morphological Transformation,Detection Event Log,Bounding Box Visualization,SmolVLM2,Template Matching,VLM As Classifier,Image Contours,Image Slicer,Stability AI Outpainting,Anthropic Claude,Environment Secrets Store,Roboflow Custom Metadata,Multi-Label Classification Model,SAM2 Video Tracker,Barcode Detection,Roboflow Asset Library Attributes,Camera Calibration,Morphological Transformation,Detections Stabilizer,Path Deviation,Relative Static Crop,Mask Area Measurement,Background Color Visualization,Model Monitoring Inference Aggregator,Clip Comparison,Corner Visualization,GeoTag Detection,SIFT,Track Class Lock,Dominant Color,Moondream2,Property Definition,Roboflow Visual Search,OpenRouter,Identify Changes,Bounding Rectangle,Overlap Analysis,Llama 3.2 Vision,Qwen3.5-VL,CLIP Embedding Model,Email Notification,Single-Label Classification Model,Triangle Visualization,OpenAI,Pixel Color Count,Roboflow Dataset Upload,OC-SORT Tracker,Image Preprocessing,First Non Empty Or Default,SIFT Comparison,YOLO-World Model,Halo Visualization,Label 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"
]
}