***

title: InfoGathererAgent
slug: /reference/typescript/agents/prefabs/info-gatherer-agent
description: An info gatherer agent that sequentially collects named fields from a caller through conversational interaction with validation and completion callbacks.
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[agentbase]: /docs/server-sdks/reference/typescript/agents/agent-base

[functionresult]: /docs/server-sdks/reference/typescript/agents/function-result

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.

```typescript {3}
import { InfoGathererAgent } from '@signalwire/sdk';

const agent = new InfoGathererAgent({ /* InfoGathererConfig */ });
```

## InfoGathererConfig

<ParamField path="fields" type="InfoGathererField[]" required={true} toc={true}>
  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`.
</ParamField>

<ParamField path="introMessage" type="string" default="Hello! I need to collect some information from you. Let me walk you through it." toc={true}>
  Opening message the agent speaks when the call starts.
</ParamField>

<ParamField path="confirmationMessage" type="string" default="Thank you! I have collected all the required information." toc={true}>
  Message spoken after all required fields are gathered.
</ParamField>

<ParamField path="onComplete" type="(data: Record<string, string>) => void | Promise<void>" toc={true}>
  Callback fired when all required fields have been collected. Receives a record of
  field names to their collected values.
</ParamField>

<ParamField path="name" type="string" default="InfoGatherer" toc={true}>
  Agent display name.
</ParamField>

<ParamField path="agentOptions" type="Partial<AgentOptions>" toc={true}>
  Additional [`AgentBase`][agentbase] options forwarded to the constructor.
</ParamField>

## Built-in Tools

| Tool         | Description                                                                        | Parameters                              |
| ------------ | ---------------------------------------------------------------------------------- | --------------------------------------- |
| `save_field` | Save a collected field value, validating against the field's pattern if configured | `field_name` (string), `value` (string) |
| `get_status` | Get the current collection status showing collected and remaining fields           | (none)                                  |

## Example

```typescript {3}
import { InfoGathererAgent } from '@signalwire/sdk';

const agent = new InfoGathererAgent({
  fields: [
    { name: 'full_name', description: 'Full legal name' },
    {
      name: 'email',
      description: 'Email address',
      validation: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
    },
    {
      name: 'phone',
      description: 'Phone number',
      validation: '^\\+?\\d{10,15}$',
    },
    {
      name: 'preferred_date',
      description: 'Preferred appointment date',
    },
    {
      name: 'notes',
      description: 'Any additional notes',
      required: false,
    },
  ],
  introMessage: 'Hi! I need a few details to schedule your appointment.',
  confirmationMessage: 'All set! Your appointment details have been recorded.',
  onComplete: (data) => {
    console.log('Collected data:', data);
    // { full_name: "Jane Doe", email: "jane@example.com", ... }
  },
  name: 'appointment-scheduler',
});

agent.addLanguage({ name: 'English', code: 'en-US', voice: 'rime.spore' });
agent.promptAddSection('Brand', {
  body: 'You are scheduling appointments for Dr. Smith\'s office.',
});

agent.serve();
```

### createInfoGathererAgent

```typescript {3}
import { createInfoGathererAgent } from '@signalwire/sdk';

const agent = createInfoGathererAgent({
  fields: [
    { name: 'name', description: 'Full name' },
    { name: 'issue', description: 'Describe your issue' },
  ],
});
```