InfoGathererAgent

View as MarkdownOpen in Claude

Sequentially collects named fields from a caller through conversational interaction. Tracks fields per call, validates values with optional regex patterns, and fires an onComplete callback once all required fields are gathered.

1import { InfoGathererAgent } from '@signalwire/sdk';
2
3const agent = new InfoGathererAgent({ /* InfoGathererConfig */ });

InfoGathererConfig

fields
InfoGathererField[]Required

Fields to collect from the caller. Each InfoGathererField object has:

  • name (string, required) — Unique field name used as the key in collected data.
  • description (string, required) — Human-readable description shown to the AI agent.
  • required (boolean, default true) — Whether this field must be collected before completion.
  • validation (RegExp | string) — Optional validation pattern. Strings are compiled to RegExp.
introMessage
stringDefaults to Hello! I need to collect some information from you. Let me walk you through it.

Opening message the agent speaks when the call starts.

confirmationMessage
stringDefaults to Thank you! I have collected all the required information.

Message spoken after all required fields are gathered.

onComplete
(data: Record<string, string>) => void | Promise<void>

Callback fired when all required fields have been collected. Receives a record of field names to their collected values.

name
stringDefaults to InfoGatherer

Agent display name.

agentOptions
Partial<AgentOptions>

Additional AgentBase options forwarded to the constructor.

Built-in Tools

ToolDescriptionParameters
save_fieldSave a collected field value, validating against the field’s pattern if configuredfield_name (string), value (string)
get_statusGet the current collection status showing collected and remaining fields(none)

Example

1import { InfoGathererAgent } from '@signalwire/sdk';
2
3const agent = new InfoGathererAgent({
4 fields: [
5 { name: 'full_name', description: 'Full legal name' },
6 {
7 name: 'email',
8 description: 'Email address',
9 validation: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
10 },
11 {
12 name: 'phone',
13 description: 'Phone number',
14 validation: '^\\+?\\d{10,15}$',
15 },
16 {
17 name: 'preferred_date',
18 description: 'Preferred appointment date',
19 },
20 {
21 name: 'notes',
22 description: 'Any additional notes',
23 required: false,
24 },
25 ],
26 introMessage: 'Hi! I need a few details to schedule your appointment.',
27 confirmationMessage: 'All set! Your appointment details have been recorded.',
28 onComplete: (data) => {
29 console.log('Collected data:', data);
30 // { full_name: "Jane Doe", email: "jane@example.com", ... }
31 },
32 name: 'appointment-scheduler',
33});
34
35agent.addLanguage({ name: 'English', code: 'en-US', voice: 'rime.spore' });
36agent.promptAddSection('Brand', {
37 body: 'You are scheduling appointments for Dr. Smith\'s office.',
38});
39
40agent.serve();

createInfoGathererAgent

1import { createInfoGathererAgent } from '@signalwire/sdk';
2
3const agent = createInfoGathererAgent({
4 fields: [
5 { name: 'name', description: 'Full name' },
6 { name: 'issue', description: 'Describe your issue' },
7 ],
8});