Skip to main content
Back to how-to guides Use this pattern when you need a fixed order of questions: collect a set of fields in one step, then move on to the next step.

Concept

A GATHER inside a FLOW step belongs to that step. The step stays active until its required fields are filled. Then the flow moves to the next step with THEN. This differs from a top-level GATHER in four ways: Set REASONING: false on a collection step for deterministic behavior. Collect in one step and read the answer in the next step. This keeps the branching in ON_INPUT separate from the collection. For the model-led alternative, see Collect information with global GATHER.

Minimal working example

An appointment agent collects contact details in one step and scheduling details in the next. The phone number and notes are optional. agents/appointment-booker.agent.abl
Variable sources:
  • Every variable is a GATHER field. The customer supplies each one.
  • The confirm step reads full_name, service_type, preferred_date, and email. The optional fields are not read there.

How it works

  1. The flow enters collect_contact. The step asks for the missing required fields. It joins the prompts, one per line, in declaration order.
  2. The turn ends. The step waits for input.
  3. The customer replies. The runtime extracts values for all the step’s fields, required and optional, in one pass. A customer can give several values in one message.
  4. The runtime validates the values and stores the good ones.
  5. If required fields are still missing, the step asks again. The repeat uses the field’s retry_prompt, then its prompt, then a fixed message.
  6. When all required fields have values, the step falls through to its THEN.
Optional fields are never asked. The step checks only required fields. A step with only optional fields is complete on entry and passes straight through.

Field forms

Inside a step, write each field in one of these forms. The keys are case-insensitive.

Inheriting a top-level field

A step field inherits the properties of a top-level GATHER field of the same name. The step overrides only the properties it sets. A step field that sets nothing but required or optional, such as - notes: optional, does not override required. The inherited value stays. Add another property, such as a prompt, to override it.

Common variations

Inherit, correct, and confirm

Declare the fields once at the top level. Reference them in the step. Turn on CORRECTIONS so the customer can change a value that was already collected. Confirm in the next step with ON_INPUT. agents/card-replacement.agent.abl

Shape the step prompt

Set PRESENT for an introduction. Set PROMPT for the question text. Use {{_missingList}} or {{_missing}} for the names of the missing fields. See Collect multiple fields across a natural conversation.

Limit attempts

Set MAX_ATTEMPTS and ON_EXHAUSTED on the step. After that many failed collection attempts, the flow moves to the step you name. Use it to hand off to a person.

Per-field retry limit

max_retries counts failed validations for one field. When it runs out, the flow follows ON_ERROR for validation_error with the subtype max_retries_exceeded.

Verification

  1. Run the validator. Expect no errors and no warnings.
  2. Start the conversation. Expect the first step to ask for the name and the email together, and not for the phone number.
  3. Reply with the name and the email in one message. Expect the flow to move to the schedule step.
  4. Reply with an invalid email. Expect the step to ask again.
  5. In the card example, say “no” at the confirmation. Expect the flow to return to collect_card.
  6. In the trace, open the dsl_prompt events with the mode gather. missingFields lists what the step asked for.
  7. Open the dsl_collect events with the mode gather. They list the extracted fields.

Production readiness checklist

  • Each collection step sets REASONING: false.
  • Each step that must ask for a field marks it required.
  • Each field has a prompt.
  • Each step has a THEN, so the flow does not stall after collection.
  • Collection and ON_INPUT branching are in separate steps.
  • A step that can loop has MAX_ATTEMPTS and ON_EXHAUSTED.
  • Tests cover all values in one message, one value at a time, a bad value, and a correction.

Common mistakes

Troubleshooting

Related articles: