Skip to Content

Pointing calls at a flow

An inbound number, a single outbound call, or a test call can target a flow instead of an agent — the start agent answers.

Anywhere you point a call at an agent, you can point it at a flow instead. The flow's start agent answers; from there the call follows the handoffs. Everything else about the call — caller ID, capacity, outbound policy, prompt variables, metadata — behaves exactly as it does for a single agent.

curl -X PATCH https://api.kejue.co/v1/phone-numbers/PHONE_NUMBER_ID \
  -H "Authorization: Bearer kejue_<prefix>_<secret>" \
  -H "Content-Type: application/json" \
  -H 'If-Match: "PHONE_NUMBER_ETAG"' \
  --data '{"flow_id": "FLOW_ID", "agent_id": null}'

Where a flow can answer

TargetHow
Inbound phone numberSet flow_id on POST /v1/phone-numbers or PATCH /v1/phone-numbers/{id}. null unassigns, as with agent_id.
A single outbound callSend flow_id instead of agent_id on POST /v1/outbound-jobs.
A test callPick the flow instead of an agent in the dashboard's test-call dialog.

The same rules apply as for an agent: the flow must be active, and it must belong to your workspace.

A number targets an agent or a flow — never both

A phone number routes inbound calls to one of:

  • an agent_id, optionally with ordered SIP-header routing rules that select a different agent per call, or
  • a flow_id, whose start agent answers every call.

You cannot combine them. Routing rules name agents, and a flow's graph knows nothing about phone numbers or SIP headers, so a number carrying both would have two answers to the same question. Setting flow_id on a number that has inbound_routing_rules is rejected; clear the rules first (send []), or unset flow_id before adding rules.

When you want both header routing and a graph, pick one of these:

  • Let the flow triage. Point the number at the flow and let the start agent work out where the call belongs from the conversation itself.
  • Keep the rules. Point the number at an agent with routing rules, and use the member agents' own transfer_agent configuration for handoffs, outside a flow.

A number pointing at a flow also pins it: DELETE /v1/flows/{id} is refused while any number still targets it. Unassign the number — or archive it — and the flow archives cleanly.

Switching a number over

Moving a live number between an agent and a flow is one PATCH: send the new target and null for the old one. A routing change on a LiveKit SIP number may report status: provisioning while the provider reconciles — wait for active before testing, exactly as you would after assigning an agent. Re-sending the target a number already has is a semantic no-op: 200, unchanged ETag, no provider work.

Calls already connected keep the target they were answered with. The switch applies to the next call that arrives.

Outbound calls

An outbound job that names a flow_id dials exactly as an agent job does: scheduling, contact hours, retries, caller-ID pool selection, and capacity are unchanged, and the job's snapshot records the flow it will run. The start agent speaks first when the callee answers.

variables are rendered into the start agent's prompt using the same template grammar. They stay available to the rest of the graph for the life of the call, so an agent further along can reference a value you supplied at dial time.

There is nothing to pin. An agent job can name an exact agent_version_id; a flow has no versions, so a flow job always runs the live graph and each node's deployed agent. If you need a frozen configuration for a regulated campaign, target an agent version instead.

Test calls

A dashboard test call can target a flow; it runs the live graph, so a flow you just saved is the one you hear. That is the fastest way to check whether a condition routes the way you expected before a real caller finds out.

Campaigns still target one agent

Campaigns cannot target a flow yet — agent_id remains required, and supplying a flow is rejected. For batch outbound through a graph, create outbound jobs with flow_id directly, and pace them yourself inside your outbound policy.

Reading back which flow ran

A call started through a flow records it, alongside the agents that actually spoke during the conversation — one call record, however many handoffs happened (Calls). Archiving or editing the flow afterwards never rewrites what a finished call reports.

Needs phone-numbers:update to assign a number and calls:place-outbound to place the outbound call, plus flows:read for the flow itself.

See also

Flows · Phone numbers · Outbound calls · After a flow call

On this page