addGatherQuestion

View as MarkdownOpen in Claude

Add a question to this step’s gather_info configuration. setGatherInfo() must be called before this method.

Parameters

opts
objectRequired

Question configuration object with the following fields:

opts.key
stringRequired

Key name for storing the answer in global_data. Must be unique within this step’s gather questions.

opts.question
stringRequired

The question text to present to the caller.

opts.type
stringDefaults to string

JSON schema type for the answer parameter.

  • "string" — text value
  • "integer" — whole number value
  • "number" — numeric value including decimals
  • "boolean" — true or false value
opts.confirm
booleanDefaults to false

When true, the AI must confirm the answer with the caller before accepting it.

opts.prompt
string

Extra instruction text appended for this specific question.

opts.functions
string[]

Additional function names to make visible while asking this question.

Returns

Step — Self for method chaining. Throws an error if setGatherInfo() has not been called first.

Example

1import { ContextBuilder } from '@signalwire/sdk';
2
3const builder = new ContextBuilder();
4const ctx = builder.addContext('default');
5const intake = ctx.addStep('intake');
6intake.setText('Collect patient information.');
7intake.setGatherInfo({
8 outputKey: 'patient_info',
9 completionAction: 'next_step',
10 prompt: 'Be friendly and professional when collecting information.',
11});
12intake.addGatherQuestion({
13 key: 'full_name', question: 'What is your full name?', confirm: true,
14});
15intake.addGatherQuestion({
16 key: 'date_of_birth',
17 question: 'What is your date of birth?',
18 type: 'string',
19 prompt: 'Spell it back to confirm.',
20});
21intake.addGatherQuestion({
22 key: 'insurance_id',
23 question: 'What is your insurance ID number?',
24 functions: ['verify_insurance'],
25});
26ctx.addStep('review').setText('Review the collected information with the patient.');