Build an IVR menu
Combine Collect digits with case routing to build a press-1-for-sales menu that branches on the caller's input.
A standard IVR menu reads a prompt and routes the call based on which digit the caller pressed. In hey-quad, this is a single Collect digits node with cases wired off it — no separate branch node needed.
Steps
-
Open the call-flow editor for your phone number.
-
Drag in a Collect digits node after your Answer call step.
-
Set the Prompt to something like:
Welcome to Acme. Press 1 for sales, 2 for support, or stay on the line for the next available agent.
-
Set Allowed digits to
12(only 1 and 2 are valid). -
Set Max digits to collect to
1and End-of-input key to blank — single-digit menus don't need a#. -
Add cases on the gather node:
vars.gatheredDigits == 1→ wire to your Sales queue enqueue.vars.gatheredDigits == 2→ wire to your Support queue enqueue.
-
Wire the right-edge out transition (the fallthrough) to the same place stay-on-the-line should go.
That's the whole menu. No additional branch nodes, no manual switch statements.
Why cases-on-the-node
The Collect digits node supports inline cases — when call.gather.ended fires, it dispatches based on the captured digit before falling through to the static on[event] map. This keeps the canvas clean: one node, one set of branches, no separate routing logic.
The same cases pattern is supported by Set / update variable, Branch on variable, and Run script.
Multi-digit collection
For PINs or extension transfers, set Min digits + Max digits > 1 and pick a terminating digit (typically #). The caller can submit early by pressing the terminating digit, or stop typing and let the Initial wait / Time between digits timeouts trigger the gather.
Validation + retries
- If the caller presses an invalid digit (not in Allowed digits), the runtime fires
call.gather.invalid. Wire a separate edge to retry with a "sorry, that's not a valid option" prompt. - If they don't press anything,
call.gather.timeoutfires. Wire an edge to a friendlier follow-up: "I didn't catch that — let me transfer you to an agent." - If you don't wire those edges, the runtime falls back to
call.gather.endedwith the empty-digit reason.
Common gotchas
- Cases only run on the success event. A timeout or invalid attempt won't dispatch cases — wire dedicated edges for those failure modes.
- Allowed digits is a whitelist, not a regex. It's just the literal characters the caller can press (digits +
*+#). - Audio prompts work too. Switch the prompt type from Text to Audio and pick a recorded MP3 if you want a specific voice.
