Building on lifecycle actions, this example adds smart routing—different follow-up paths based on user preferences.Documentation Index
Fetch the complete documentation index at: https://docs.syllable.ai/llms.txt
Use this file to discover all available pages before exploring further.
Objective
In this example, you’ll learn:- How to use conditional
nextentries for branching logic - How to write JMESPath expressions for conditions
- How to create parallel workflow paths with different endings
- The importance of fallback routes
The Scenario
Your contact form collects the user’s preferred contact time. Now you want to:- Route morning/afternoon preferences → schedule a phone call
- Route evening/night preferences → send an email follow-up
Implementation
Here’s the complete tool definition:Key Concepts
Conditional next Entries
The next array can contain multiple entries with conditions:
- Entries are evaluated in order (top to bottom)
- The first entry whose condition evaluates to true wins
- An entry without
ifis a fallback (always matches) - If no entries match, the submission is treated as terminal and the workflow completes in place
JMESPath Expressions
JMESPath is the default expression language for conditions. Common patterns:flag == \true`(notflag == true`)count >= \3`(notcount >= 3`)
Variable Access in Conditions
Afteron.submit actions execute, you can access:
| Variable | Access Pattern |
|---|---|
| Saved global variables | contact_time (directly by name) |
| Task-local variables | local.steps_completed |
| Current step inputs | inputs.contact_time |
save action runs before transition evaluation, so contact_time is available for routing decisions.
Fallback Routes
Always include a fallback route (noif condition) as the last entry:
Multiple Terminal Steps
This example has two terminal steps (SCHEDULE_CALL and SEND_EMAIL), each with:
- Unique instructions tailored to that path
- No inputs (confirmation only)
- Empty
next: [](terminal)
How It Works
Path A: Morning/Afternoon Preference
Path B: Evening/Night Preference
Workflow Structure
Try It
To test this workflow in the Syllable Console:- Create a new tool with the JSON above
- Assign it to an agent
- Test both paths:
- Say “morning” as your preferred time → expect phone call confirmation
- Say “evening” as your preferred time → expect email confirmation
What’s Next
This example routes based on valid input, but what if the user provides invalid data? In Example 6: Retry Loop, you’ll learn how to:- Validate email format before proceeding
- Allow retry attempts when validation fails
- Use counters to limit retries
- Loop back to the same step on failure

