Skip to main content

Overview

Form tools display interactive forms within the chat widget to collect structured data from users. Use them for:
  • Lead capture
  • Contact forms
  • Support ticket creation
  • Surveys and feedback
  • User onboarding
Form in widget

Creating a Form Tool

Field Types

Ansa supports 11 field types:

Text Input

Single-line text entry.

Email

Email input with format validation.

Phone (Tel)

Phone number input.

Number

Numeric input with optional min/max.

Textarea

Multi-line text input.

Select (Dropdown)

Single selection from options.

Multi-Select

Multiple selections from options.

Date

Date picker.

DateTime

Date and time picker.

File Upload

File upload (max 5MB, base64 encoded).

Image Upload

Image upload (max 5MB, base64 encoded).

Field Properties

Every field supports these properties:

Validation

Add validation rules with custom error messages:

Required

Min/Max Length (Text)

Min/Max Value (Numbers/Dates)

Pattern (Regex)

Combined Validation

Default Values

Static Defaults

Template Defaults

Use user data to pre-fill fields:
Available template variables:
  • {{user.email}} — Identified user’s email
  • {{user.name}} — Identified user’s name
  • {{user.userId}} — User ID
  • {{user.metadata.field}} — Any custom metadata field
  • {{context.previousResult.field}} — Data from previous tool result

Form Schema

The complete form structure:

Execution Modes

Control how form submissions are handled:
See Triggering Forms in Code for client-side handling.

Complete Example

A comprehensive lead capture form:

See Also