# Data Collection (/docs/agents/voice-agents/data-collection)

> For the complete documentation index, see [llms.txt](https://docs.tandemcx.ai/llms.txt). Any page on this site can be fetched as Markdown by appending `.md` to its URL.

<Callout type="info">
    **This page is being rolled out.** If your agent editor has no **Data Collection** step, it
    isn't enabled for your organization yet. Contact support.
</Callout>

An agent can collect details from a caller or chat visitor, such as a name, an email address, or
a preferred date. You list the fields on the agent. During the conversation the agent asks for
each one, checks the answer, and saves it as it goes.

## Set up the fields

1. Open the agent and step to **Data Collection** in the stepper. The **Data Collection** card
   lists the agent's fields.
2. Click **Data Collection Fields** in the card header. The panel opens on the side.
3. Optionally pick a template from **Start from template**, or click **Add Field** to build the
   list yourself.
4. Save the agent and publish the version. Live calls and chats run the published version, so
   the fields have no effect until you publish. See
   [Versioning](/docs/agents/voice-agents/versioning).

An agent has 1 to 25 fields, asked in the order you list them. Each field has:

- **Label**: what the field is called, up to 80 characters. It is also the heading above the
  value on the conversation record.
- **Key**: a lowercase name the agent uses to record the field. It starts with a letter and
  uses letters, digits, and underscores, up to 40 characters. Keys are unique within an agent.
- **Type**: what kind of value the field holds. See [Field types](#field-types).
- **Required**: whether the agent treats the field as required.
- **What to ask**: optional guidance for how the agent asks, up to 500 characters. Leave it
  empty and the agent words the question from the label.

An agent with no fields collects nothing. The **Data Collection** step is there for voice and
chat agents alike.

### Templates

**Start from template** offers four templates. A template copies its fields into the panel, so
editing them never changes the template, and later changes to a template never reach agents you
already set up. Every field is editable afterwards.

If the agent already has fields, picking a template asks **Replace your fields?** first. **Replace
Fields** swaps the whole list for the template's. **Keep My Fields** leaves it alone. Nothing is
saved until you save the agent.

| Template                | Fields                                                                                               |
| ----------------------- | ---------------------------------------------------------------------------------------------------- |
| **Contact details**     | Full name (required), Email address (required), Phone number                                         |
| **Mailing address**     | Full name, Mailing address (required), Postal code (required)                                        |
| **Appointment request** | Full name (required), Phone number (required), Preferred date (required), Reason for the appointment |
| **Callback request**    | Full name (required), Phone number (required), Best time to call back                                |

Agent templates carry the fields too. An agent you create from an [agent
template](/docs/agents/voice-agents/templates) starts with the fields the source agent had, and
a template you save from an agent records its current fields.

## Field types

The agent checks each value against its field's type before saving it. If the value fails, the
agent is told why and asks again. Some types also normalize the value before it is saved.

| Type                           | What it checks                                                                                | What is saved                        |
| ------------------------------ | --------------------------------------------------------------------------------------------- | ------------------------------------ |
| **Full name**                  | 1 to 200 characters                                                                           | As given                             |
| **Email**                      | Has a name, an `@`, and a domain                                                              | Lowercased                           |
| **Phone number**               | A dialable number                                                                             | E.164 format, such as `+14155550123` |
| **Mailing address**            | 5 to 500 characters                                                                           | As given                             |
| **Postal code**                | 3 to 10 letters or digits, with an optional space or hyphen                                   | As given                             |
| **Date**                       | A real calendar date as `YYYY-MM-DD`                                                          | As given                             |
| **Date of birth**              | A real date as `YYYY-MM-DD`, not before 1900 and not in the future                            | As given                             |
| **Number**                     | Digits with an optional minus sign and decimal point, up to 50 characters. Commas are allowed | Commas removed                       |
| **Yes / No**                   | `yes`, `y`, `true`, `no`, `n`, or `false`                                                     | `yes` or `no`                        |
| **Code (letters and numbers)** | 1 to 64 characters once spaces are removed                                                    | Spaces removed, uppercased           |
| **Free text**                  | 1 to 2,000 characters                                                                         | As given                             |

Values are trimmed first, and an empty value is never accepted.

## How the agent collects

On a call, the agent is instructed to ask for one field at a time, in its own words, using what
you wrote in **What to ask**. It takes a value the caller volunteers at any point and does not
ask again for a field it already has. It saves a value once it is confirmed. If the caller cannot
or will not give one after two tries, the agent is instructed to record the field as not
provided and move on rather than hold the caller. These are instructions to the model, not a
rule the platform enforces.

In chat, the agent works the same way and can also show an entry box for a field. It does this
for values that are easier to type than to say in a message, such as an email address, a
postal address, a date, or a code. The box appears under the agent's message, with the field's
label, a **Submit** button, and **Skip**. A Yes / No field shows **Yes** and **No** buttons
instead of a text box, plus **Skip**. The visitor's answer is validated like a spoken one, and an
invalid value shows an error in the box. **Skip** records the field as not provided. Either way
the agent sees the answer as if the visitor had typed it and carries on.

A required field marks what the agent should aim to collect. It does not stop a caller or visitor
from skipping it.

## Read what was collected

Open a call or chat in **Insights → Call Logs**. When the agent collected something, a **Collected
Data** panel sits under the conversation summary, above the recording and transcript. It lists
each field's label and value, in the order the agent recorded them. A field the person declined
shows **Not provided**, with the reason below it. A conversation where nothing was collected has
no panel.

A parent organization's Call Logs does not show a [sub-tenant's](/docs/overview/sub-tenants)
collected data. Switch to the sub-tenant to read it.

A submission is created when the first field is saved, so a conversation that ended early can show
only some of the fields.

If the conversation was transferred to another agent, the panel has one block per agent, headed
by the agent's name. Each block holds what that agent collected.

The same values are available over the API:

- [Get what the agent collected on a call](/docs/api/voice-agents/data-collection/getCallCollectedData)
- [Get what the agent collected in a chat](/docs/api/voice-agents/data-collection/getChatCollectedData)

The fields themselves are the `dataCollection` setting of the agent configuration.

## Limits and defaults

- **1 to 25 fields per agent**, with unique keys.
- **One set of fields per agent.** To collect different information from different callers, use
  separate agents or put all the fields on one.
- **Retention is 90 days** after a submission's last update, then it is removed.
- **Editing the fields does not change past records.** Each saved value keeps the label it had
  when it was recorded, so an older conversation still reads correctly after you rename or
  remove a field.
- **Test conversations are not kept.** Collection works in the chat widget editor's preview chat
  and in browser test calls, so you can try your fields. The browser test call runs the draft in
  the editor, so it needs no publish. The preview chat runs the published version, so publish
  first. Those entries do not show on call or chat records and are removed after 1 day.

## Next steps

- [Built-in tools](/docs/agents/voice-agents/built-in-tools)
- [Preview calls](/docs/agents/voice-agents/preview-calls)
- [Chat widget](/docs/agents/chat-widget)
