> ## Documentation Index
> Fetch the complete documentation index at: https://kapso-1adbad2d.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Flow class

> Create and manage WhatsApp workflows

## Basic usage

```python theme={null}
from kapso.builder.flows import Flow
from kapso.builder.flows.nodes import StartNode, SendTextNode

flow = Flow(
    name="customer_onboarding",
    description="Onboard new customers via WhatsApp"
)

# Add nodes  
flow.add_node(StartNode(id="start_1234"))
flow.add_node(SendTextNode(
    id="send_text_5678",
    message="Welcome to our service!"
))

# Connect nodes
flow.add_edge("start_1234", "send_text_5678")

flow.validate()
```

The backend automatically falls back to the WhatsApp configuration tied to the conversation. Only set `whatsapp_config_id` on a node when you need to override that default.

## Constructor

```python theme={null}
Flow(
    name: str,
    description: str = None
)
```

* **name**: Flow identifier (alphanumeric + underscores)
* **description**: Optional description

## Methods

### add\_node()

```python theme={null}
flow.add_node(node)
```

Add a node to the flow. Each node needs a unique ID.

### add\_edge()

```python theme={null}
flow.add_edge(source, target, label="next")
```

Connect two nodes by their IDs.

```python theme={null}
flow.add_edge("start_1234", "greeting_5678")
flow.add_edge("decide_9012", "help_3456", label="needs_help")
```

### validate()

```python theme={null}
flow.validate()
```

Check flow structure. Required before deployment.

* Must have exactly one StartNode
* All nodes must be reachable from StartNode
* No duplicate node IDs

## Node IDs

Node IDs use format `{type}_{timestamp}`:

```python theme={null}
StartNode(id="start_1234567890")
SendTextNode(id="send_text_1234567891", ...)
DecideNode(id="decide_1234567892", ...)
```
