***

title: addGatherQuestion
slug: /reference/typescript/agents/context-builder/step/add-gather-question
description: Add a question to this step's gather_info configuration.
max-toc-depth: 3
---------------------

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

[set-gather-info]: /docs/server-sdks/reference/typescript/agents/context-builder/step/set-gather-info

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

Add a question to this step's gather\_info configuration.
[`setGatherInfo()`][set-gather-info]
must be called before this method.

## **Parameters**

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

<Indent>
  <ParamField path="opts.key" type="string" required={true} toc={true}>
    Key name for storing the answer in `global_data`. Must be unique within
    this step's gather questions.
  </ParamField>

  <ParamField path="opts.question" type="string" required={true} toc={true}>
    The question text to present to the caller.
  </ParamField>

  <ParamField path="opts.type" type="string" default="string" toc={true}>
    JSON schema type for the answer parameter.

    * `"string"` -- text value
    * `"integer"` -- whole number value
    * `"number"` -- numeric value including decimals
    * `"boolean"` -- true or false value
  </ParamField>

  <ParamField path="opts.confirm" type="boolean" default="false" toc={true}>
    When `true`, the AI must confirm the answer with the caller before accepting it.
  </ParamField>

  <ParamField path="opts.prompt" type="string" toc={true}>
    Extra instruction text appended for this specific question.
  </ParamField>

  <ParamField path="opts.functions" type="string[]" toc={true}>
    Additional function names to make visible while asking this question.
  </ParamField>
</Indent>

## **Returns**

[`Step`][ref-step] -- Self for method chaining. Throws an error if `setGatherInfo()`
has not been called first.

## **Example**

```typescript {12-14,15-20,21-25}
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,
});
intake.addGatherQuestion({
  key: 'date_of_birth',
  question: 'What is your date of birth?',
  type: 'string',
  prompt: 'Spell it back to confirm.',
});
intake.addGatherQuestion({
  key: 'insurance_id',
  question: 'What is your insurance ID number?',
  functions: ['verify_insurance'],
});
ctx.addStep('review').setText('Review the collected information with the patient.');
```