Skip to main content
Building on lifecycle actions, this example adds smart routing—different follow-up paths based on user preferences.

Objective

In this example, you’ll learn:
  • How to use conditional next entries 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:
  1. Route morning/afternoon preferences → schedule a phone call
  2. Route evening/night preferences → send an email follow-up
This creates personalized experiences based on user input.

Implementation

Here’s the complete tool definition:

Key Concepts

Conditional next Entries

The next array can contain multiple entries with conditions:
Evaluation rules:
  1. Entries are evaluated in order (top to bottom)
  2. The first entry whose condition evaluates to true wins
  3. An entry without if is a fallback (always matches)
  4. 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:
Important: In JMESPath, boolean and numeric literals require backticks:
  • flag == \true`(notflag == true`)
  • count >= \3`(notcount >= 3`)

Variable Access in Conditions

After on.submit actions execute, you can access: The save action runs before transition evaluation, so contact_time is available for routing decisions.

Fallback Routes

Always include a fallback route (no if condition) as the last entry:
This prevents the workflow from getting stuck if none of the conditions match.

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)
The user’s journey ends differently based on their preference:

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:
  1. Create a new tool with the JSON above
  2. Assign it to an agent
  3. Test both paths:
    • Say “morning” as your preferred time → expect phone call confirmation
    • Say “evening” as your preferred time → expect email confirmation
Verify the routing: Each path should deliver different confirmation messages based on the user’s preference.

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