***

title: setGatherInfo
slug: /reference/typescript/agents/context-builder/step/set-gather-info
description: Enable structured info gathering for this step.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[add-gather-question]: /docs/server-sdks/reference/typescript/agents/context-builder/step/add-gather-question

[ref-step]: /docs/server-sdks/reference/typescript/agents/context-builder/step

Enable info gathering for this step. Call
[`addGatherQuestion()`][add-gather-question]
after this method to define the questions.

The gather\_info system collects structured information from the caller by
presenting questions one at a time. It uses dynamic step instruction re-injection
rather than tool calls, producing zero `tool_call`/`tool_result` entries in
LLM-visible history.

## **Parameters**

<ParamField path="opts" type="object" toc={true}>
  Optional configuration object with the following fields:
</ParamField>

<Indent>
  <ParamField path="opts.outputKey" type="string" toc={true}>
    Key in `global_data` to store collected answers under. When `undefined`, answers are
    stored at the top level of `global_data`.
  </ParamField>

  <ParamField path="opts.completionAction" type="string" toc={true}>
    Where to go when all questions are answered.

    * `"next_step"` -- auto-advance to the next sequential step
    * A step name (e.g., `"process_results"`) -- jump to that specific step
    * `undefined` -- return to normal step mode after gathering
  </ParamField>

  <ParamField path="opts.prompt" type="string" toc={true}>
    Preamble text injected once when entering the gather step, giving the AI
    personality and context for asking the questions.
  </ParamField>
</Indent>

## **Returns**

[`Step`][ref-step] -- Self for method chaining.

## **Example**

```typescript {7-16}
import { ContextBuilder } from '@signalwire/sdk';

const builder = new ContextBuilder();
const ctx = builder.addContext('default');
const intake = ctx.addStep('intake');
intake.setText('Collect patient information.');
intake.setGatherInfo({
  outputKey: 'patient_info',
  completionAction: 'next_step',
  prompt: 'Be friendly and professional when collecting information.',
});
intake.addGatherQuestion({
  key: 'full_name',
  question: 'What is your full name?',
  confirm: true,
});
ctx.addStep('review').setText('Review the collected information with the patient.');
```