> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # InfoGathererAgent > A prefab agent that collects answers to a series of questions — supporting both static and dynamic (per-request callback) modes. [agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base [functionresult]: /docs/server-sdks/reference/typescript/agents/function-result Sequentially asks a caller a list of questions and stores each answer in `global_data`. Supports **static mode** (questions provided at construction) and **dynamic mode** (questions resolved per request via a callback). ```typescript {3} import { InfoGathererAgent } from '@signalwire/sdk'; const agent = new InfoGathererAgent({ /* InfoGathererConfig */ }); ``` ## InfoGathererConfig **`questions`** `InfoGathererQuestion[]` Questions to ask (static mode). Each `InfoGathererQuestion` has: * `key_name` (string, required) — key used to store the caller's answer. * `question_text` (string, required) — the question to ask. * `confirm` (boolean) — when `true`, the agent insists the caller confirms the answer before moving on. Omit this field to run the agent in dynamic mode (see `questionCallback` / `setQuestionCallback()`). --- **`questionCallback`** `InfoGathererQuestionCallback` Convenience alternative to calling `setQuestionCallback()` after construction. Consulted only when `questions` is not provided. Signature: ```typescript (queryParams, bodyParams, headers) => InfoGathererQuestion[] | Promise ``` If the callback throws or is not registered in dynamic mode, the agent falls back to a built-in two-question list (name + "how can I help"). --- **`name`** `string` — default: "info\_gatherer" Agent display name. --- **`route`** `string` — default: "/info\_gatherer" HTTP route for the agent. --- **`agentOptions`** `Partial` Additional [`AgentBase`][agentbase] options forwarded to the constructor. --- ## **Methods** ### setQuestionCallback ```typescript setQuestionCallback(callback: InfoGathererQuestionCallback): this ``` Register (or replace) the callback that resolves questions per request. Only used in dynamic mode (when `questions` was not supplied at construction). ## Built-in Tools | Tool | Description | | ----------------- | --------------------------------------------------------------- | | `start_questions` | Begin the question sequence with the first question. | | `submit_answer` | Submit the caller's answer to the current question and advance. | ## Example — static mode ```typescript {3} import { InfoGathererAgent } from '@signalwire/sdk'; const agent = new InfoGathererAgent({ questions: [ { key_name: 'full_name', question_text: 'What is your full name?' }, { key_name: 'email', question_text: 'What is your email address?', confirm: true }, { key_name: 'issue', question_text: 'How can we help you today?' }, ], name: 'intake-agent', }); agent.serve(); ``` ## Example — dynamic mode ```typescript {3-14} import { InfoGathererAgent, type InfoGathererQuestion } from '@signalwire/sdk'; const agent = new InfoGathererAgent({ questionCallback: async (queryParams) => { const tenant = queryParams['tenant'] ?? 'default'; const rows = await db.loadQuestions(tenant); return rows.map((r) => ({ key_name: r.key, question_text: r.prompt, confirm: r.requiresConfirmation, })); }, }); agent.serve(); ``` ### createInfoGathererAgent ```typescript {3} import { createInfoGathererAgent } from '@signalwire/sdk'; const agent = createInfoGathererAgent({ questions: [ { key_name: 'name', question_text: 'What is your name?' }, { key_name: 'issue', question_text: 'Describe your issue' }, ], }); ``` > A prefab agent that collects answers to a series of questions — supporting both static and dynamic (per-request callback) modes.