setGatherInfo

View as MarkdownOpen in Claude

Enable info gathering for this step. Call addGatherQuestion() 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

opts
object

Optional configuration object with the following fields:

opts.outputKey
string

Key in global_data to store collected answers under. When undefined, answers are stored at the top level of global_data.

opts.completionAction
string

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
opts.prompt
string

Preamble text injected once when entering the gather step, giving the AI personality and context for asking the questions.

Returns

Step — Self for method chaining.

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',
14 question: 'What is your full name?',
15 confirm: true,
16});
17ctx.addStep('review').setText('Review the collected information with the patient.');