# Flow Basics (/docs/workflows/flow-basics)

> For the complete documentation index, see [llms.txt](https://docs.tandemcx.ai/llms.txt). Any page on this site can be fetched as Markdown by appending `.md` to its URL.

A workflow (or "flow") is a graph of **nodes**, where each node represents a
single step. Execution begins at the **initiator** node and follows the
connections between nodes based on each node's output. A flow runs once per
conversation — a call, message, or other interaction — carrying its own set of
variables from start to finish.

## Anatomy of a flow

Every flow is built from three things:

- **Nodes** — the steps. Each node does one thing (send a message, branch on a
  condition, query data) and is configured through its fields.
- **Exits** — the labeled outputs on a node. A node like Condition has `true`
  and `false` exits; most action nodes have a single `default` exit. Each exit
  is a possible path the flow can take next.
- **Connections (edges)** — the wires from one node's exit to the next node's
  input. They define the order steps run in.

<Callout>
    A node's exits are fixed by its type. You don't create exits, you wire the ones the node already
    has. The [node reference](/docs/workflows/reference) lists the exits for every node.
</Callout>

## Adding nodes

There are multiple ways to add nodes:

- **Click the `+` beside an exit** that isn't connected yet. Search for a node, and it's added
  to the right of that node and connected to that exit.
- **Add Node**, at the left of the controls at the bottom of the canvas, searches for a node and
  adds it to the canvas unconnected. An empty workflow also shows **Add Node** in the middle of
  the canvas.
- **Right-click the canvas** to search and add a node by name.
- Press `Cmd/Ctrl+P` to open the **Node Library** and drag nodes onto the canvas.
- **Drag from a node's exit handle** onto empty canvas to create and connect a
  node in one step.
- Press `Cmd/Ctrl+K` to search and add from the keyboard.

## Connecting nodes

Drag from a node's exit handle to another node's input to create a connection.
Each **exit** represents a possible path the flow can take.

A single exit connects to exactly one next node, but many exits (from different
nodes, or the different exits of one node) can point into the same node — that's
how branches rejoin. To remove a connection, select the edge and press `Delete`
or `Backspace`.

## The initiator node

Every flow must have an **initiator** node to define where execution begins. Set
any node as the initiator from its context menu.

<Callout type="warn">
    An initiator must be set for a workflow to pass validation and be published.
</Callout>

## Branching

Use **Condition** or **Switch** nodes to send the flow down different paths:

- **Condition** evaluates a true/false test (optionally combining several checks
  with AND/OR) and routes to a `true` or `false` exit.
- **Switch** matches a single value against many cases and routes to the exit for
  the first match — reach for it instead of chaining Conditions when one value
  selects among several outcomes.

A branch doesn't have to stay separate forever: wire two exits into the same
downstream node to bring the paths back together once the branch-specific work
is done.

## A worked example

A simple after-hours voice flow ties these ideas together:

<Steps>
    <Step>**Initiator** — the call arrives and starts the flow.</Step>
    <Step>
        A **Time Control** node checks the current time against your business hours. It routes to a
        matching event's exit, or to `default` when no event matches.
    </Step>
    <Step>
        During hours, wire the exit to a **Transfer to Queue** node so a live agent picks up. After
        hours, wire it to a **Play Message** node that states your hours.
    </Step>
    <Step>End the after-hours path with a **Disconnect** node to hang up.</Step>
</Steps>

## Next steps

<Cards>
    <Card
        title="Getting Started"
        href="/docs/workflows/getting-started"
        description="Build and publish your first workflow end to end."
    />
    <Card
        title="Editing Nodes"
        href="/docs/workflows/editing-nodes"
        description="Configure, remove, and duplicate nodes."
    />
    <Card
        title="Execution & Publishing"
        href="/docs/workflows/execution-and-publishing"
        description="Validate, publish, and version a flow."
    />
    <Card
        title="Variables & Data"
        href="/docs/workflows/variables-and-data"
        description="Store data and reference it across nodes."
    />
</Cards>
