InfoGathererAgent

View as MarkdownOpen in Claude

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).

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:

(queryParams, bodyParams, headers) => InfoGathererQuestion[] | Promise<InfoGathererQuestion[]>

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
stringDefaults to "info_gatherer"

Agent display name.

route
stringDefaults to "/info_gatherer"

HTTP route for the agent.

agentOptions
Partial<AgentOptions>

Additional AgentBase options forwarded to the constructor.

Methods

setQuestionCallback

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

ToolDescription
start_questionsBegin the question sequence with the first question.
submit_answerSubmit the caller’s answer to the current question and advance.

Example — static mode

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

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<InfoGathererQuestion>((r) => ({
key_name: r.key,
question_text: r.prompt,
confirm: r.requiresConfirmation,
}));
},
});
agent.serve();

createInfoGathererAgent

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' },
],
});