Skip to navigation

set_gather_info

View as MarkdownOpen in Claude

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

output_key
str | NoneDefaults to None

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

completion_action
str | NoneDefaults to None

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
  • None — return to normal step mode after gathering
prompt
str | NoneDefaults to None

Preamble text that gives the model personality and context for asking the questions. It’s sent with every question, ahead of the question’s own text, and each copy replaces the one before. Under the "keep" history mode, only the first question’s copy is sent, and it stays.

isolated
boolDefaults to False

Default for every question in this gather. When True, each question is asked with the sibling questions and answers hidden from the model, so it must ask rather than derive the answer from an earlier one. A question’s own isolated overrides this. Hidden turns stay in the call log.

say_questions
boolDefaults to False

When True, the platform says each question word for word, its ${...} values filled in, when the gather reaches it, and the model is told the caller was just asked. The answer still goes through gather_submit: the model checks it, does any confirm read-back, and asks again in its own words if the answer is unclear or the caller stays silent. A question’s own say overrides this.

Realtime models ask every question themselves, and a platform release without this feature ignores it, so the model asks.

Returns

Step — Self for method chaining.

Examples

Gather with a preamble

from signalwire import AgentBase
agent = AgentBase(name="my-agent", route="/agent")
contexts = agent.define_contexts()
ctx = contexts.add_context("default")
intake = ctx.add_step("intake")
intake.set_text("Collect patient information.")
intake.set_gather_info(
output_key="patient_info",
completion_action="next_step",
prompt="Be friendly and professional when collecting information."
)
intake.add_gather_question(
key="full_name",
question="What is your full name?",
confirm=True
)
ctx.add_step("review").set_text("Review the collected information with the patient.")
agent.serve()

Questions the platform says itself

from signalwire import AgentBase
from signalwire.core.contexts import expected_answer
agent = AgentBase(name="survey", route="/survey")
agent.prompt_add_section("Role", "You run a short survey.")
ctx = agent.define_contexts().add_context("default")
step = ctx.add_step("survey").set_text("Ask the survey questions.").set_functions("none")
step.set_gather_info(output_key="survey", completion_action="next_step", say_questions=True)
step.add_gather_question("zip", "What is your ZIP code?", expected_answer=expected_answer(5))
step.add_gather_question("pin", "What is your PIN?", say=False,
expected_answer={"min_digits": 4, "max_digits": 6})
ctx.add_step("done").set_text("Thank the caller.").set_functions("none")
agent.serve()

The platform says the ZIP code question itself; the model asks for the PIN.