add_gather_question

View as MarkdownOpen in Claude

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

Parameters

key
strRequired

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

question
strRequired

The question text to present to the caller.

type
strDefaults 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
confirm
boolDefaults to false

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

prompt
str | NoneDefaults to None

Extra instruction text appended for this specific question.

functions
list[str] | NoneDefaults to None

Additional function names to make visible while asking this question.

isolated
bool | NoneDefaults to None

Override the gather’s isolated default for this one question. True hides the sibling questions and answers while this question is asked; False keeps them visible even in an isolated gather. None inherits the gather’s setting.

Returns

Step — Self for method chaining. Raises ValueError if set_gather_info() has not been called first.

Example

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
)
intake.add_gather_question(
key="date_of_birth",
question="What is your date of birth?",
type="string",
prompt="Spell it back to confirm."
)
intake.add_gather_question(
key="insurance_id",
question="What is your insurance ID number?",
functions=["verify_insurance"]
)
ctx.add_step("review").set_text("Review the collected information with the patient.")
agent.serve()