Branch on an AI decision
AI is great at judgement calls: is this email urgent? which category is this? But a judgement is only useful in a flow if you can act on it — and you can’t reliably branch on a paragraph of prose. The fix is to make the AI step return a typed value: not “Well, this looks fairly urgent…”, but exactly urgent.
A typed value turns a fuzzy AI judgement into a real, predictable value you can route on. Ask AI → Switch (or Branch) gives you deterministic routing off an AI decision — classify an email and send each kind down a different path, every time.
Typed answers, not prose
Section titled “Typed answers, not prose”The Ask AI step has a Response format setting. Leave it on Free text and you get prose. Change it, and Routario coerces the model’s reply into a real value and puts it in the step’s ai_parsed output:
| Response format | You get back |
|---|---|
| Free text | The text as written |
| Integer | A whole number |
| Decimal | A number with decimals |
| Yes / no | A true/false value |
| JSON | A parsed object |
| JSON list | A parsed list |
| Choice | Exactly one value from a list you define |
Read the typed result downstream as {{ <label>.ai_parsed }} — for example {{ classify.ai_parsed }}. (The raw, uncoerced text is still available at {{ classify.ai_response }} if you want it.)
Choice is the one that unlocks routing, so the rest of this guide focuses on it.
Choice: one of a fixed list
Section titled “Choice: one of a fixed list”Pick Choice as the response format and you supply a list of allowed values. Routario steers the model to answer with exactly one of them, then checks the reply against your list and hands back your value. If the model goes off-script, the step fails loudly rather than passing junk downstream.
Setting the list of choices
Section titled “Setting the list of choices”You type the allowed values into the Enum values field. Routario is forgiving about how you write them — all of these produce the same list, [rock, paper, scissors]:
| You enter | Parsed list |
|---|---|
["rock","paper","scissors"] (chips / JSON) | [rock, paper, scissors] |
rock, paper, scissors (commas) | [rock, paper, scissors] |
rock paper scissors (spaces) | [rock, paper, scissors] |
rock; paper; scissors (semicolons) | [rock, paper, scissors] |
rock ,, paper , (stray spaces / empties) | [rock, paper] (blanks dropped) |
| (empty) | the step errors — Choice needs values |
How a reply is matched
Section titled “How a reply is matched”Once the model answers, Routario matches it against your list. Matching is lenient about formatting but strict about content — the result is always one of your exact values, in your casing. With the list [rock, paper, scissors]:
| The model returns | Result |
|---|---|
rock | rock |
Rock or ROCK | rock — matching ignores case, returns your casing |
"rock". | rock — surrounding quotes and . , ! ? ' " are stripped |
rock (with stray spaces or a newline) | rock — surrounding whitespace is stripped |
I'd pick rock | error — not an exact value |
lizard | error: Response 'lizard' is not one of: rock, paper, scissors |
A reply that doesn’t match raises an error and the run fails on that step — which is what you want: a misclassification should stop and surface, not quietly flow into the wrong branch. (In practice this is rare: the step instructs the model to answer with just one of the values.)
Worked example: triage incoming support email
Section titled “Worked example: triage incoming support email”Every inbound support email is auto-sorted into urgent, normal, or spam and routed down a different path.
-
Incoming email trigger. The flow starts when a message arrives at the flow’s own inbox address. The trigger hands the email to the steps that follow as plain values —
{{ from }},{{ subject }},{{ body }}, and any{{ attachments }}. -
Classify it with Ask AI (label:
classify). Add an Ask AI step and set the prompt to:Classify this support email.Subject: {{ subject }}Body: {{ body }}Set Response format to Choice and Enum values to
urgent, normal, spam. The decision is now available as{{ classify.ai_parsed }}— guaranteed to be exactly one of those three. -
Route on the decision with a Switch. Switch on
{{ classify.ai_parsed }}, with one case per value:- urgent → a Send notification step that pings the on-call channel.
- normal → add it to the queue — a Create record in your tickets table, or a Create task.
- spam → leave the case with no onward step; the run just ends and the message is dropped.
Why the Choice format is what makes this work
Section titled “Why the Choice format is what makes this work”Step 3 can switch on a clean value — urgent — because step 2 is guaranteed to return one of the three options. If step 2 were Free text and replied “This looks pretty urgent to me”, the Switch would have nothing reliable to match. Typed Choice is the contract that lets a deterministic Switch sit downstream of a fuzzy AI judgement.
It ties straight back to the two tables above: the three values can be entered as chips or as urgent, normal, spam; a reply of Urgent or urgent. still resolves to urgent; and a reply of maybe urgent? errors rather than guessing.
Where to go next
Section titled “Where to go next”- Switch and Branch — the routing steps that act on the decision.
- Ask AI — reference — every field on the AI step, including the other response formats.
- Routing a flow — how branching, switching, and merging fit together.