Skip to main content
Back to how-to guides Use this pattern when flow steps, routing, templates, or tools need known session values before the user says anything.

Concept

ABL gives you several places to seed session values. Pick the one that matches where the value comes from. ON_START runs these steps in order:
  1. SET assignments.
  2. The top-level CALL.
  3. Interaction language directives.
  4. BRANCHES conditions and the welcome RESPOND.
  5. The matched branch DO: list.
ON_START runs once per session, for the entry agent only. A specialist reached by handoff never runs its own ON_START. ON_START also runs when the first user message starts the session, before the runtime processes that message. A reconnect to an initialized session does not run it again. Keep initialization deterministic. Use it for values that exist at start. Collect values from the user with GATHER.

Values you can read at start

A path with no value resolves to nothing. A template then renders it as empty text.

Minimal working example

How it works

  • SET assignments run before RESPOND, in the order you write them.
  • A numeric or boolean constant keeps its type. 0 stays a number.
  • A top-level RESPOND is a prelude. The entry flow step still runs at start and asks for the order number.
  • The flow reads the initialized values from the first step on.
  • SET runs on every channel. Some channels, such as Slack, WhatsApp, and API, do not deliver the welcome. The values are still set.
  • You can write several assignments under one SET: line, one per line.
  • An unresolved path leaves the variable empty.

Common variations

Initialize constants

Quote text constants. An unquoted word that matches a session variable name reads that variable. An unquoted word with no match is stored as text.
In a real project, copy values such as a campaign marker from trusted caller data, for example SET: campaign_id = session.campaign_id.

Declare a default with INITIAL

Use INITIAL for a fixed default. The runtime writes it when it creates the session. It also fills the variable when an agent activates and the variable is still missing.
A variable that has only an INITIAL value and no other writer triggers the W801 warning. Write the variable somewhere, as the SET in show_attempt does.

Set a value for one branch

SET in a branch DO: list runs after the welcome, so the welcome cannot read it. The compiler reports ON_START_BRANCH_DO_ACTIVATED as an informational warning.

Pin the reply language on a voice channel

SET_INTERACTION_LANGUAGE applies only on a voice channel that has a supported-language list. On other channels the override is not applied, and the trace shows the reason.

Verification

  1. Start a session. In the trace, find one dsl_set event for each top-level SET, with source: on_start.
  2. Answer the first question. Confirm the final reply shows the initialized values.
  3. Start a session on a second channel. Confirm channel_name changes.
  4. For SET_INTERACTION_LANGUAGE, look for the interaction_language_override_changed event.
  5. Reconnect to the same session. Confirm ON_START does not run again.

Production readiness checklist

  • Initialize only values available before the first user turn.
  • Quote text constants.
  • Keep names consistent with later WHEN, PASS, and template references.
  • Set shared values in the entry agent. Pass them to specialists with PASS.
  • Avoid writing sensitive values unless the flow needs them.
  • Trace every startup assignment during validation.
  • Test each target channel, including channels that do not deliver the welcome.

Common mistakes

Troubleshooting