> ## 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

A **logic flow** is a graph of nodes that performs a specific task: looking up data, calling an API, sending a message, or running branching logic. Logic flows act as tools the agent can invoke from the conversation flow when it needs to execute an action.

Each logic flow is its own graph with a [Start](/configure/nodes#start) node as its entry point. You wire nodes together to define the steps, connect branches, and pass data through the flow.

## How logic flows relate to the conversation

The conversation flow controls what the agent says and when. Logic flows handle what the agent does. When the agent reaches a point in the conversation where it needs to execute an action (look up a customer, send an email, check a condition), it invokes the appropriate logic flow as a tool.

You connect a logic flow to the conversation by adding a **Function** node to your conversation graph and selecting the flow you want to call. The agent sees the flow's name and description as a tool it can invoke.

## Flow structure

Every logic flow follows the same structure:

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

* **Start** is always the entry point. Every flow has exactly one.
* Nodes are connected left to right (or top to bottom) with edges.
* A flow ends when execution reaches a node with no outgoing connection.
* Variables set inside a flow are available call-wide - the conversation flow can reference them after the flow completes.

## Edges

Edges connect one node to the next. Most nodes have a single outgoing **default** edge. Branching nodes produce multiple edges:

| Edge label     | Source node            | Meaning                                                          |
| -------------- | ---------------------- | ---------------------------------------------------------------- |
| `default`      | Any non-branching node | Standard connection to the next step.                            |
| `if`           | Condition              | Taken when the condition evaluates to true.                      |
| `else`         | Condition              | Taken when the condition evaluates to false.                     |
| Category value | Categorize             | One edge per category; taken when the LLM selects that category. |

## Branching and merging

Use **Condition** or **Categorize** to split the flow into branches, and **Merge** to bring branches back together before continuing with shared logic.

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

Both the `if` and `else` paths connect into the Merge node. Execution continues from Merge once either branch completes.

## Passing variables into a flow

When you call a logic flow from a **Flow** node, you pass variables into it using the node's `variables` field. Each entry is an [InputVariable](/configure/variables) that maps a value (static or dynamic) to a parameter name the flow can reference.

Variables passed in are available to all nodes within that flow execution. Variables set by nodes inside the flow (via Variable, Extract, Webhook response, etc.) are written to the call-wide variable scope and accessible everywhere after the flow runs.

## Async nodes

The **Webhook** and **Integration** nodes support an `async` flag. When enabled:

* The agent speaks the `asyncMessage` while the request runs in the background.
* The flow continues after the async node without waiting for the response.
* Use this when the external call may take a moment and you don't want silence on the line.

## 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.

## Tips

* Keep flows focused on a single task. A flow that does one thing is easier to reuse and debug.
* Use the **Variable** node at the start of a flow to set defaults before your logic runs.
* Use **Transform** after a Webhook or Integration to reshape the response into the variable names your conversation flow expects.
* Test flows independently using the flow test runner before connecting them to a live agent.
