Skip to main content
Back to how-to guides Use this pattern when the first assistant message needs the signed-in user’s identity, such as a display name or account status.

Concept

Authentication and profile lookup are separate jobs. The channel authenticates the user before the session starts. A profile lookup reads business data for that identity. ON_START can call a read-only lookup tool before the welcome renders. The runtime puts the authentication result in the session namespace when the channel supplies it. Treat caller data from a browser as unverified. Use session.identityTier for decisions that need a verified identity. Do not reveal sensitive data before identity is verified. Greet generically when the identity is missing. ON_START runs these steps in order:
  1. SET assignments.
  2. The top-level CALL, only when its WHEN guard is true.
  3. Interaction language directives.
  4. BRANCHES conditions. The first match supplies the welcome.
  5. The welcome RESPOND.
  6. The matched branch DO: list.
A top-level CALL finishes before the branch conditions and the welcome. Both can read its result. A CALL inside a branch DO: list runs after the welcome, so the welcome cannot use its result. The welcome waits for the tool. Keep the tool fast and set hints.timeout as a number of milliseconds.

Minimal working example

This example calls a profile tool only for a signed-in customer. It shows a generic welcome in every other case.
The tool needs an execution binding in your project, such as an HTTP endpoint. This example assumes that binding exists.

How it works

  • WHEN: session.customerId IS SET skips the lookup for anonymous users. Indent WHEN under CALL. A sibling WHEN is ignored and the parser warns.
  • AS: accountProfile stores the tool result. If the tool fails or does not run, accountProfile.display_name stays unset.
  • The first branch matches only when display_name is set. Otherwise the ELSE branch shows a generic welcome.
  • Without the branch guard, a missing field renders as empty text, for example “Hello . Your account is .”.
  • A matched branch owns the startup turn. In a FLOW agent, the entry step runs on the first user message instead of at start.

Common variations

Gate on identity without a lookup

Use this when the welcome only needs to know whether the user is verified.

Prefetch the profile after the welcome

Use a branch DO: list when the welcome does not need the profile. The welcome renders first. The call then fills accountProfile for the first turn.
If the call fails, the list stops and the welcome stays as shown. The compiler reports ON_START_BRANCH_DO_ACTIVATED as an informational warning. It confirms that the list runs at session start.

Look up by a channel-supplied identifier

If the channel passes an account ID as caller data, use session.account_id in both WITH and WHEN. Check the exact key name your channel sends.

Verification

Run three sessions and inspect the trace for each.
  1. Start as a verified user. Expect the personalized welcome. In the trace, dsl_lifecycle_call_condition shows matched: true, and dsl_call shows source: on_start_with. Then tool_call_start, tool_result, dsl_on_start_branch, and dsl_respond appear.
  2. Start anonymously. Expect the generic welcome. dsl_lifecycle_call_condition shows matched: false, and no dsl_call event appears.
  3. Start as a verified user while the tool fails. Expect the generic welcome. dsl_on_start_branch shows the ELSE branch.
Check that no account detail appears in the anonymous transcript.

Production readiness checklist

  • Bind get_account_profile to a read-only endpoint in the project.
  • Return only the fields the welcome needs.
  • Set hints.timeout as a plain number of milliseconds.
  • Keep a generic ELSE welcome for anonymous users and tool failures.
  • Test verified, anonymous, tool failure, and tool timeout sessions.
  • Confirm the target channel delivers the ON_START welcome.
  • Trace the startup tool call and review lookup failures.

Common mistakes

Troubleshooting