Lead capture
Collect leads with pre-chat forms and the capture_lead tool, define fields, get email notifications, manage leads, and export them.
Last updated:
Many chats are really sales enquiries. Lead capture lets your agent collect contact details in the conversation, validates them, saves them to a list your team can work through, and can email you the moment someone shares their details. There are two ways to collect leads, which you can use together.
| Pre-chat form | capture_lead tool | |
|---|---|---|
| When | Before the chat starts, shown by the widget. | During the conversation, when the AI decides the visitor wants follow-up. |
| Who decides | You (every visitor sees it, optionally skippable). | The agent, guided by your instructions. |
| Best for | Support desks that need to know who is writing; gated chats. | Sales and enquiry flows where forcing a form would lose visitors. |
Define your fields#
Lead fields are defined in the agent builder under lead capture. Each field has:
- Key: a short machine name made of lowercase letters, digits and underscores, such as
emailorcompany_size. Keys must be unique. They appear in exports and webhooks. - Label: what the visitor and the agent see (up to 80 characters).
- Type:
text,email,tel,textarea,numberorselect. - Required: whether the lead is accepted without it.
- Options: for
select, up to 20 choices (each up to 80 characters).
You can define up to 12 fields. The default set is a name (optional) and an email address (required). Values are validated on the server: emails must be valid addresses, phone numbers must look like phone numbers, numbers must be numeric, and select values must be one of the options. Keep forms short: every extra required field costs conversions. Name and email, or email and one qualifying question, is usually enough.
{
"lead_capture": {
"fields": [
{ "key": "name", "label": "Name", "type": "text", "required": false },
{ "key": "email", "label": "Email", "type": "email", "required": true },
{ "key": "company", "label": "Company", "type": "text", "required": false },
{ "key": "interest","label": "I am interested in","type": "select", "required": false,
"options": ["Pricing", "A demo", "Support"] }
],
"notify_emails": ["[email protected]"],
"instructions": "Offer to take their details when they show buying interest or ask for follow-up."
}
}
This is the shape stored for the agent, shown for reference. You normally edit these settings through the dashboard forms rather than writing JSON.
The capture_lead tool#
The built-in capture_lead tool is on by default. The AI is given your fields as the tool's inputs and asked to call it when it has collected the required values. The instructions text (up to 1,000 characters) tells the agent when to offer this. Make it specific:
Offer to take the visitor's details when they ask about pricing for more than 5 seats, ask for a demo, or say they want someone to contact them. Ask for name and email in one friendly message. Do not ask again if they have already given them. After saving, confirm what happens next: "Thanks, our team will email you within one working day."
There is one lead per conversation: if the visitor shares more details later in the same chat, they are merged into the existing lead rather than creating a duplicate, and notifications are sent only once, when the lead is first created. The name, email and phone values are also remembered as visitor attributes, so the agent does not ask for them again and your team sees them in the inbox. Playground tests never create real leads, notifications or webhook events, so test lead capture from the live widget.
The agent asks for any missing required details in conversation. If a value fails validation (for example, a malformed email), the tool returns the problem to the agent, which asks the visitor to correct it. Visitors never see raw error messages.
Pre-chat form#
Turn on the pre-chat form to collect details before the first message:
- Enabled: show the form when the visitor opens the chat.
- Title: the heading, default "Before we start".
- Required: if on, the visitor must submit the form before they can send a message. If off, they can skip it.
- Fields: up to 12, defined the same way as above. The default is an optional name and an optional email.
Submitted values become visitor attributes, so the agent can use them ({{visitor.name}}, {{visitor.email}}) and your team sees them in the inbox. Because the pre-chat form is collected before any message, make sure your privacy notice covers it, and consider the widget's consent text option. See Widget customization.
Notifications#
Add up to 10 addresses to notification emails and each captured lead is emailed to them. Email is sent by SiteTrellis from its own sending address, so if notifications land in spam, ask your team to allow it, and check the troubleshooting guide. You can also send leads to your CRM or automation tool in real time by subscribing a webhook to the lead.captured event. See Webhooks (available on Starter plans and above).
Managing leads#
Open Leads in the dashboard. Each row shows the captured fields, the site and agent, the time, and a link to the conversation that produced it. People with the Agent role can see leads for the workspaces they belong to.
- Status: new, contacted, qualified or closed. Move leads along as your team works them.
- Notes: add internal notes to a lead.
- Search and filter by status, site or date.
- Export the list to CSV to import into your CRM or spreadsheet.
On Pro and Agency plans, post-chat analysis can also summarise each finished conversation and extract extra structured fields from it, such as a budget or a company name. See Analytics and unanswered questions.
Good practice#
- Be upfront. Say why you are asking and what happens next. Visitors are more willing to share details.
- Collect the minimum. Only ask for what you will use. It also reduces your privacy obligations.
- Respond fast. A lead answered within minutes converts far better than one answered the next day. Use notification emails or a webhook into a chat or CRM tool your team watches.
- Combine with handoff. If a visitor is ready to buy and someone is online, a live takeover beats a form. See Escalation and live takeover.
- Handle the data lawfully. Leads are personal data. See Security and privacy for how to delete them.