Midio docs
  • Getting Started
    • Welcome
    • Quick Start Guide
  • Your First Midio App
  • Guides
    • HTTP
      • Making HTTP Requests
      • Responding to HTTP Requests
      • How to reach your own endpoints
      • CORS
      • Server-Sent Events (SSE)
    • Branching
    • Loops
    • Map, filter, reduce
    • Working with Data
    • Expressions
    • Building Agents
      • Streaming Agent API (experimental)
    • Debugging
    • Secrets and Environment variables
    • Convert JSON to data nodes
    • Writing tests
    • Cleaning up your flows
  • Package Manager
  • Integrating with third party services
  • Troubleshooting
  • Tutorials
    • Connecting LLMs to MCP-servers using the MCP-client package
    • Making Your Own MCP Server in Midio
    • A Fast Path to Functional RAG Agents
    • How to build a streaming agent using Server-Sent Events (SSE)
  • Reference
    • The Midio Editor
      • The Node Editor
      • User Traces
      • Traces (execution)
      • Processes
      • Log
      • Services
      • Problems
      • Function Signature
      • Data
      • Settings
    • The Midio Language
      • Nodes and execution
      • Functions and Events
        • Anonymous functions
      • Modules
      • Contexts
      • Data type
      • Local variables
      • Portals
      • Waypoint node
      • Partial function application
  • The Midio Engine
  • Built in Nodes
    • Core (std)
    • HTTP
    • LLM
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Guides

Branching

PreviousServer-Sent Events (SSE)NextLoops

Last updated 2 months ago

Was this helpful?

Branching allows your flows to make decisions based on conditions, directing execution along different paths depending on the given input. The If node is commonly used for this purpose, allowing you to define logic where execution follows one path if a condition is met and another if it is not.

  1. Generating a Value: In the example above, the Random node produces a number between 0 and 10, which is sent to the If node.

  2. Evaluating a Condition: The If node checks if the value is greater than 5 using the predicate input.

  3. Branching Execution: If true, execution follows the then path; if false, it follows the else path.

  4. Logging the Result: One of the Log nodes prints either “Value is large” or “Value is small” based on the condition.

There are several other branching nodes, wich support various use-cases:

- is used to select one of two values based in two potentially incoming paths

- is used to select a fallback value when you have a value which can potentially be null.

- is used to create an arbitrary number of branches based on a list of potential values.

// - these nodes can be used to fork a flow into multiple independenc processes, which execute concurrently and can be joined together again using Std Join and .

Std Switch
Std OrElse
Std Match
Std Fork
Std FanOutRange
Std FanOutList
Std JoinAll