Skip to main content
Building on the multi-step flow, this example adds lifecycle actions to create a polished user experience with welcome messages and progress tracking.

Objective

In this example, you’ll learn:
  • How to use on.enter hooks to execute actions when entering a step
  • How to use the say action for verbatim text delivery
  • How to use the set action to initialize variables
  • How to use the inc action to track progress with counters
  • How to combine multiple actions in lifecycle hooks

The Scenario

Your contact form from Example 3 works, but feels robotic—no greeting, no sense of progress. You want to:
  1. Welcome users at the start
  2. Show progress indicators (“Step 1 of 3”, “Step 2 of 3”, etc.)
  3. Track how many steps have been completed
This creates a friendlier, more professional experience.

Implementation

Here’s the complete tool definition:

Key Concepts

The on.enter Hook

The on.enter hook executes when the workflow enters a step, before the agent starts collecting inputs:
Use on.enter for:
  • Welcome messages and progress indicators
  • Initializing step-local variables
  • Pre-populating inputs from existing data

The on.submit Hook

The on.submit hook executes after validation passes, before evaluating transitions:
Use on.submit for:
  • Persisting inputs to global variables
  • Updating counters
  • Triggering side effects (like tool calls)

The say Action

The say action queues text that the agent must include verbatim:
The agent receives this text as part of the step instructions and includes it in the response. This significantly improves verbatim compliance compared to prescribing exact wording only in the main prompt, though the agent may still introduce minor variations.

The set Action

The set action initializes or updates a variable:
Variables can be:
  • Task-local (local.*): Scoped to this workflow instance
  • Global (no prefix): Shared across the conversation

The inc Action

The inc action increments a numeric counter:
If the variable doesn’t exist, it’s created with value 0 before incrementing. Optional: specify a custom increment amount:

Enum Constraints

The COLLECT_TIME step uses an enum to constrain the contact time:
This forces the agent to normalize user input:
  • “8am” → “morning”
  • “after lunch” → “afternoon”
  • “around 7pm” → “evening”
This normalization is essential for reliable conditional branching in Example 5.

How It Works

Here’s the conversation flow:

State After Each Step

After COLLECT_NAME:
After COLLECT_EMAIL:
After COLLECT_TIME:

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. Start a conversation and say “hello”
  4. Notice the welcome message and progress indicator
  5. Complete all three steps
  6. Observe how the agent normalizes contact time to one of the enum values
Test the enum: Try saying “8am” or “after lunch” and see how the agent maps it to “morning” or “afternoon”.

What’s Next

This example collects contact time but treats all preferences the same. In Example 5: Conditional Branching, you’ll learn how to:
  • Route to different steps based on user input
  • Use JMESPath expressions for conditions
  • Create parallel workflow paths