← cd ../articles

One diagram instead of a dozen pages: a visual call flow editor built on React Flow

20 October 2026 · 15 min read

  • React
  • React Flow
  • UX
  • TypeScript
share: LinkedIn X

Call routing in a cloud phone system is made of small pieces. A phone number rings a phone menu. The menu sends key 1 to a ring team and key 2 to a waiting line. Outside opening hours, a message plays and the caller ends up in voicemail. Each piece is simple. The call is the sum of them.

The product I work on had one settings page per piece: phone numbers, phone menus, opening hours, extensions, ring teams, waiting lines, forwarding, voicemail, conference rooms, messages, and a few more. A dozen entries under Call Routing in the sidebar.

The Ring Teams page: a table with one ring team, its members, labels and exit destination, and the Call Routing menu in the sidebar listing thirteen pages
One page per entity. Each row knows where it sends the call next, and nothing else.

Where customers got lost

Every page was fine on its own. The trouble was in between them.

To set up “calls go to the menu during the day, to voicemail at night”, a customer had to create the voicemail first, then the closed-hours message pointing at it, then the menu, then the opening hours rule pointing at both, and finally point the phone number at the rule. Five pages, in that order, because each record can only point at something that already exists.

And once it was built, nobody could see it. The only place the routing existed as a whole was in the customer’s head. A question like “what happens if someone presses 2 at 7 pm?” meant opening four pages and following the Destination dropdowns by hand. Support tickets were full of exactly that: a call ending up somewhere unexpected because one pointer on one page pointed at the wrong thing.

The same routing as separate pages and as one flow On the left, five separate pages: phone number, opening hours, phone menu, ring team and voicemail, each with a destination field naming the next one. The customer has to follow the names from page to page. On the right, the same five records drawn as a connected flow from the phone number to the opening hours, the menu, the ring team and the voicemail, with the closed branch going to a message and then voicemail. Before · one page each Phone number destination: Office hours ▾ Opening hours open: Welcome menu ▾ · closed: … Phone menu key 1: Sales team ▾ · key 2: … Ring team no answer: Front desk ▾ Voicemail (end of the call) the path lives in your head After · one flow Number Hours Menu Message Ring team Voicemail open closed key 1 no answer
The same five records. On the left you follow names from page to page; on the right you just look.

People read a diagram faster than a list of settings. If someone draws a call on a whiteboard, they draw boxes and arrows, not five forms. So that is what we built: a Call Flow Studio where the whole call is one picture.

The Studio: the call as a picture

The Call Flow Studio: an extension goes to Opening Hours, whose open branch goes to a Phone Menu and closed branch to a Play Message node. The menu's keys lead to a Ring Team, a Waiting Line, a Forward and Hang Up, and everything ends in a Voicemail node.
A whole line, start to finish: opening hours, a phone menu, three teams and one voicemail.

Every box is one routing record. Every outlet on a box is one of its exits: a menu has an outlet per key, opening hours has Open and Closed, a waiting line has Timeout, No agents and Queue full. Every line is one pointer: “this exit sends the call there”. The question “what happens if someone presses 2 at 7 pm?” now takes a glance: follow Closed Hours.

Building a flow is drag, drop and connect. A node comes from the palette on the right, and you pull a line from an exit to the next node:

Building a flow: an extension 100 named Reception is added, a Ring Team node is dragged onto the canvas and connected, then a Voicemail node is dragged in and connected to the ring team
New lines are dashed until the flow is saved.

Clicking a node opens the same form its own page would show, in the side panel. You can pick an existing record (“use the Sales team ring team”) or create a new one right there, without leaving the canvas.

The Phone Menu node is selected, and the side panel shows its form: existing menu, name, labels, main audio and thresholds
The node's form lives next to the canvas, so the picture never goes away while you edit.

One rule: the diagram is a view, not a second copy

The decision that shaped everything else: the Studio does not store its own routing. A flow is a projection of the same records the dozen pages edit. The old pages are still there, and they edit the same rows. Change a ring team’s exit on its page, and the line moves in the Studio. Draw a new line in the Studio, and the ring team’s page shows the new destination.

We could have stored the flow as a JSON document and compiled it into routing on save. That is easier to build, and it guarantees two truths that drift apart: the diagram says one thing and the call does another. Customers would trust neither.

So the mapping is direct:

How a canvas node maps to a routing record On the left, a Ring Team node on the canvas with its input handle and its no-answer exit, connected by an edge to a Voicemail node. On the right, the stored records: the ring team row with id rt_8f2, its members, and two pointer columns, exit kind voicemail and exit id vm_31c, and the voicemail row with id vm_31c. The node is identified by the key ring_team:rt_8f2, the edge is the pair of pointer columns, and the node's position is kept separately in the flow's layout. Canvas · React Flow Ring Team Sales team no answer ↘ Voicemail Front desk node · handle · edge · position Routing records · the source of truth ring_team · rt_8f2 name: "Sales team" members: [Alice] exit_kind: "voicemail" exit_id: "vm_31c" voicemail · vm_31c name: "Front desk" flow layout: { "ring_team:rt_8f2": {x, y} } key edge
A node is a row, an exit is a pointer column on that row, and only the positions belong to the flow.
  • A node is a row, identified by a key like ring_team:rt_8f2 (kind plus id).
  • An edge is a pointer on the source row: a ring team’s “no answer” exit is its exit_kind + exit_id columns.
  • A handle is the name of the exit: default, timeout, match and no_match, digit:1.
  • The only thing the flow owns is where the boxes sit: a map from node key to { x, y }.

That last point matters. Customers arrange their diagrams by hand, and they want the boxes to stay where they put them. Positions are layout, not routing, so they are the one thing stored on the flow itself.

React Flow does the canvas

The canvas is React Flow: panning, zooming, selection, handles and edge drawing come for free. What we wrote is the domain on top.

One custom node type for everything. Every kind of record renders through the same StudioNode component: an icon, a title, the record’s name, and a row per exit, each with its own source handle. A config table says what each kind looks like:

export const NODE_CONFIG: Record<NodeType, NodeConfig> = {
  [NodeType.Menu]: {
    label: "Phone Menu",
    hasInput: true,
    outputType: "multiple",
    outputs: [
      { id: "default", label: "Default" },
      { id: "key-1", label: "Key 1" },
      // … keys 0–9, * and #
    ],
  },
  [NodeType.Voicemail]: { label: "Voicemail", hasInput: true, outputType: "none" },
  // …
}

Adding a new kind of record to the Studio is one entry here, one form, and one schema.

Drag and drop from the palette is the browser’s own drag API. The palette item puts the node type in the drag data, and the canvas turns the drop point into canvas coordinates with React Flow’s screenToFlowPosition, so it lands in the right place at any zoom level:

const handleDrop = (event: React.DragEvent) => {
  event.preventDefault()
  const type = event.dataTransfer.getData("application/reactflow")
  if (!isNodeType(type)) return

  const position = screenToFlowPosition({ x: event.clientX, y: event.clientY })
  addNode(type, position)
}

State lives in a store, not in React Flow. Nodes, edges, the selected node and an undo history sit in a zustand store, and React Flow only renders them. That keeps the save logic, validation and undo out of components and testable on their own.

Auto-Arrange: ELK draws the boxes for you

A flow loaded for the first time has no positions yet: it came from records created on the old pages. And a flow you have been editing for an hour tends to look like a plate of spaghetti. Both need the same thing: a sensible layout, computed.

React Flow deliberately leaves layout to you. We use ELK (through elkjs) with its layered algorithm, left to right, the way people read a call:

const graph = {
  id: "root",
  children: nodes.map((node) => ({
    id: node.id,
    width: NODE_WIDTH,
    height: heightOf(node), // a menu with 12 keys is taller than a voicemail
    ports: portsOf(node),   // one port per exit, in display order
    layoutOptions: { "elk.portConstraints": "FIXED_ORDER" },
  })),
  edges,
  layoutOptions: {
    "elk.algorithm": "layered",
    "elk.direction": "RIGHT",
    "elk.layered.crossingMinimization.strategy": "LAYER_SWEEP",
    "elk.layered.nodePlacement.strategy": "NETWORK_SIMPLEX",
    "elk.spacing.nodeNode": "80",
    "elk.layered.spacing.nodeNodeBetweenLayers": "100",
  },
}

The detail that made the result readable: ports with a fixed order. Without them, ELK treats a node as a point and connects lines to wherever is shortest, so “Key 3” can end up drawn above “Key 1”. With one port per exit in display order, the lines leave each box in the same order the labels show, and ELK minimises crossings around that.

A messy flow with overlapping nodes and crossing lines snaps into a clean left-to-right layout after clicking Auto-Arrange Flow
One click: from a plate of spaghetti back to a readable left-to-right flow.

Layout runs automatically for nodes that have no saved position, and on demand from the Auto-Arrange Flow button. Positions you set by hand are saved with the flow, so a reopened flow looks exactly as you left it.

Validation: point at the box that is wrong

On the old pages, a form could not be saved until it was valid. On a canvas you build in any order, that would be maddening: you drop five boxes, then fill them in. So the Studio lets you draw freely and checks everything when you press Save.

Each node kind has a zod schema, the same one its form uses. Save runs every node through its schema; the invalid ones turn red, and a click on one opens its form with the field that needs attention:

export function validateNodeConfig(type: NodeType, config: unknown): ZodError | null {
  const schema = FORM_SCHEMAS[type]?.schema(t)
  if (!schema) return null
  const result = schema.safeParse(config)
  return result.success ? null : result.error
}

One rule kept this from getting in the way: only nodes created or edited in this session are checked. A record loaded with the flow, or picked as an existing one, is not written by the save, and it may hold values another screen allowed. Blocking a save on something the customer never touched would be a bug report waiting to happen.

Save shows a validation error and the new Voicemail node turns red. Clicking it opens its form, a name is typed in, and the second Save succeeds with a Flow saved successfully message
The error points at the box, and the box opens the form that fixes it.

Saving: records first, then the picture

Because the flow is a view over records, saving is two steps, in a fixed order:

What happens when you press Save Save first validates the nodes created or edited in this session against their schemas. If any fail, the save stops and those nodes are marked red. If all pass, step two writes the records: new nodes are created and edited ones updated, so every node has a row id. Step three sends the graph, the list of node keys, the edges as pointers and the layout, in one request guarded by the flow's version tag. If someone else saved the flow meanwhile, the request is refused instead of overwriting their change. Finally, the undo history is cleared. 1 · Validate zod, edited nodes 2 · Write records create · update 3 · Send the graph keys · edges · layout 4 · Clear undo ids are real Stop invalid nodes go red Refused if stale If-Match: flow version a node needs its row id before a line can point at it
Every node gets a real record before the graph that connects them is sent.
  1. Write the records. A node dragged in from the palette has no row yet, and a line cannot point at something that does not exist. So new nodes are created and edited ones updated first, and every node ends up with a real id.
  2. Send the graph. Then one request sends the node keys, the edges as pointers, and the layout. The server applies the pointers to the rows in one go.
  3. Guard against the other tab. The graph request carries the flow’s version tag. If a colleague saved the same flow in the meantime, the save is refused instead of silently overwriting their change.

A small detail that followed from the order: after a successful save, the undo history is cleared. Undoing past a save would bring back nodes without the ids that were just created, and the next save would create those records a second time. Losing undo across a save is a much smaller surprise than a duplicate ring team.

What changed for customers

The pages are still there, and some people still prefer them for a quick edit. But setting up routing, and above all understanding it, moved to the diagram.

  • The order problem is gone. You draw the call in the order you think about it, start to end, and the save works out the order the records must be created in.
  • “Where does this call go?” is answered by looking, not by opening four pages.
  • Mistakes are visible. A key that leads nowhere, or a voicemail no one can reach, shows up as a missing or dangling line instead of hiding in a dropdown.

The lesson I keep coming back to: we didn’t add any new routing features. Every capability in the Studio already existed on the dozen pages. What we changed was the shape of the interface, from a list of settings to a picture of the call, and that alone turned “I’m lost” into “oh, I see”.

Found this useful? Pass it on.

share: LinkedIn X