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

Extra instruction text appended for this specific question.

functions
list[str]

Additional function names to make visible while asking this question.

Returns

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

Example

1from signalwire import AgentBase
2
3agent = AgentBase(name="my-agent", route="/agent")
4
5contexts = agent.define_contexts()
6ctx = contexts.add_context("default")
7intake = ctx.add_step("intake")
8intake.set_text("Collect patient information.")
9intake.set_gather_info(
10 output_key="patient_info",
11 completion_action="next_step",
12 prompt="Be friendly and professional when collecting information."
13)
14intake.add_gather_question(
15 key="full_name",
16 question="What is your full name?",
17 confirm=True
18)
19intake.add_gather_question(
20 key="date_of_birth",
21 question="What is your date of birth?",
22 type="string",
23 prompt="Spell it back to confirm."
24)
25intake.add_gather_question(
26 key="insurance_id",
27 question="What is your insurance ID number?",
28 functions=["verify_insurance"]
29)
30ctx.add_step("review").set_text("Review the collected information with the patient.")
31
32agent.serve()