> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vatel.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Logic Flows

> Build reusable tools and branching logic your agent can invoke during a call

Your agent can run **logic flows** to perform structured actions during a call, such as looking up data, calling an API, sending a message, or running branching logic. Each logic flow is a self-contained, reusable tool that the agent can invoke from the main conversation whenever it needs to execute a specific task.

Every logic flow is its own graph (a visual canvas of connected nodes) with a [Start](https://docs.vatel.ai/configure/nodes.md#start) node as its entry point. You connect nodes together with edges to define the sequence of steps, create branches for conditional logic, and pass data through the flow.

## Why use a logic flow?

Many of the things you can do in a logic flow (webhooks, conditions, sending messages) can also be placed directly on the conversation flow. The key difference is **determinism**, and understanding this distinction is important for building reliable agents.

In the **conversation flow**, the LLM decides what happens next at each step. This means there is no guarantee that a particular node will execute in a specific order, or that it will execute at all. The model might skip a step, run steps out of order, or take a different path depending on how the conversation unfolds.

Inside a **logic flow**, every node runs deterministically in the exact order you wired them. The LLM only makes one decision: whether to invoke the flow. Once the flow starts, the steps inside it execute exactly as you defined them, every time, with no model involvement.

This makes logic flows the right choice when you need a reliable, predictable sequence of actions. For example, if you need to call an API, check the response status, branch on whether the customer is found, and send a confirmation message, placing those steps in a logic flow guarantees they run in that exact order every time.

## Creating a logic flow

1. On the **Main Flow**, expand **Function** in the sidebar and click **Run Sub Flow** to add it to your canvas.

![Adding a Run Sub Flow node from the Function menu](https://mintcdn.com/devpro-38b0cd42/hdbCFLBnzC5gA6Ir/images/configure/capabilities/logic-flow-add-subflow.png?fit=max\&auto=format\&n=hdbCFLBnzC5gA6Ir\&q=85\&s=7d47b56ebd14c01fb2c1304bd2575585)

2. Click the **Main Flow** dropdown at the top of the graph and click **+ New** to create a new flow. Give it a name and description. This creates a new flow graph starting with a Start node where you can place any nodes you need.

![Creating a new flow from the flow dropdown](https://mintcdn.com/devpro-38b0cd42/hdbCFLBnzC5gA6Ir/images/configure/capabilities/logic-flow-create-flow.png?fit=max\&auto=format\&n=hdbCFLBnzC5gA6Ir\&q=85\&s=416e465adb26053339730c8fc00fc3fa)

3. Go back to the **Main Flow**, select the Run Sub Flow node you added in step 1, and choose your new flow from the **Flow Graph** dropdown.

![Selecting the new flow graph in the Run Sub Flow node](https://mintcdn.com/devpro-38b0cd42/hdbCFLBnzC5gA6Ir/images/configure/capabilities/logic-flow-select-flow.png?fit=max\&auto=format\&n=hdbCFLBnzC5gA6Ir\&q=85\&s=14c52553c9cdae887d49cb8ec6ba70b0)

The agent now sees this flow as a tool it can invoke during the conversation. The LLM decides when to call it, but once it runs, every step inside executes deterministically.

## Flow structure

Every logic flow follows the same basic structure.

```
Start → [nodes] → [end of flow]
```

* **Start** is always the entry point. Every flow has exactly one Start node, and execution always begins there.
* Nodes are connected left to right (or top to bottom) using edges (arrows). Each edge defines which node runs next.
* A flow ends when execution reaches a node with no outgoing connection. There is no explicit "End" node; the flow simply stops when there is nowhere left to go.
* Variables set inside a flow are available call-wide (not just within the flow), so the main conversation flow and other logic flows can reference them after this flow completes.

## Edges

Edges are the arrows that connect one node to the next in the graph. They define the execution order. Most nodes have a single outgoing edge labeled **default**, which simply means "go to the next step." Branching nodes (like Condition and Categorize) produce multiple outgoing edges, one for each possible path.

| Edge label | Source node | When this path is taken |
| - | - | - |
| `default` | Any non-branching node | Always. This is the standard "continue to the next step" connection. |
| `if` | Condition | When the condition's comparison evaluates to true. For example, if you configured the condition to check whether `customer.tier` equals `"premium"`, this edge is taken when the value is indeed `"premium"`. |
| `else` | Condition | When the comparison evaluates to false, or when the two values being compared are incompatible types (for example, comparing a string to a number). Think of this as the "otherwise" path. |
| *(category name)* | Categorize | The Categorize node asks the LLM to classify something into one of several categories you define. Each category gets its own outgoing edge. The edge matching the LLM's chosen category is taken. For example, if you define categories "billing," "technical," and "general," the flow follows whichever edge matches the classification result. |

## Branching and merging

You can split a flow into separate paths using a **Condition** or **Categorize** node, and then bring those paths back together using a **Merge** node before continuing with shared logic.

```
Start → Condition → [if] → Action A → Merge → Next step
                 → [else] → Action B →
```

In this example, both the `if` and `else` paths connect into the same Merge node. The Merge node waits until the branch that was taken has finished executing, then continues to the next step. Only one branch actually runs (the one whose condition matched), but the Merge node is what allows both paths to rejoin into a single continuation point.

## Passing variables into a flow

When you place a **Run Sub Flow** node on the main conversation flow and select it, the settings panel includes a **Variables** section. Clicking **Add Variable** lets you define a name/value pair to pass into the flow. Each value can be either **static** (a fixed value you type in) or **dynamic** (resolved at runtime from a call variable). This Variables section only appears on the main conversation flow; it is not shown when you are editing inside a logic flow.

The variables you pass in are available to every node inside that flow. Additionally, any variables the flow sets during execution (via Set Variables, Webhooks, or other nodes) remain available in the main conversation after the flow finishes, since all variables are call-scoped.

Leaf nodes in the flow (nodes with no outgoing edge) have their output automatically added to the agent's context, just like in the Start flow. This means the agent can reference that data in conversation after the flow completes.

Note that a flow cannot call itself. Recursive flows are not supported.

## Example: look up a customer and route by tier

```
Start
  → Webhook (GET /customers?phone={{caller}})
  → Condition (customer.tier == "premium")
      → [if]   → Conversation ("Welcome back, premium member...")
      → [else]  → Conversation ("Thanks for calling...")
      → Merge
  → End of flow
```

The conversation flow calls this logic flow as a tool when the agent needs to identify the caller. After the flow completes, the variables set inside it (like `customer.tier`) are available in the conversation.

## Start and end flows

Start and End are not logic flows that you invoke as tools. The Start flow runs before the agent is connected, and the End flow runs after hangup. Leaf nodes on the Start flow are copied into the agent's context. See [Start and end flows](https://docs.vatel.ai/configure/start-end-flows) for details.

## Tips

* **Keep flows focused on a single task.** A flow that does one thing (for example, "look up customer" or "send confirmation email") is easier to reuse across agents and simpler to debug when something goes wrong.
* **Set defaults at the start.** Use a **Set Variables** node at the beginning of a flow to initialize default values before your logic runs. This prevents errors from missing variables if the flow is invoked before certain data has been captured.
* **Reshape API responses with Transform.** After a Webhook or Integration node, use a **Transform** node to rename fields, flatten nested objects, or extract just the data your conversation flow needs. This keeps your main flow clean and avoids long variable paths like `{{node.webhook1.responseBody.data.customer.profile.name}}`.
* **Test flows in isolation.** The **Run flow** button on the flow canvas lets you execute that flow by itself, without placing an actual call. This is useful for verifying that your logic, conditions, and API calls work correctly before publishing the agent.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.