JavaScript Embed Features

Client-Side Custom Forms

Custom forms let the agent render a real input UI — typed inputs, validation, dropdowns — and hand structured data back to your code.

What it does

Whenever you need clean, structured data and free text would be messy: lead capture beyond the built-in fields, booking forms with date pickers, surveys with multi-choice questions, formats with regex validation.

Registering form schemas

Define the action in the dashboard (Actions → Create action → Custom form). The form name must match the key you register client-side.

js
window.chatmount.registerFormSchema({
  learn_more_form: async (args, user) => ({
    fields: [
      {
        name: "email",
        label: "Email Address",
        type: "email",
        validation: { required: { value: true, message: "Email is required" } },
      },
    ],
    submitButtonText: "Send Message",
    successMessage: "Thank you! We'll get back to you soon.",
  }),
});

Field types

  • text, textarea, email, phone, number
  • select, multiselect, groupselect, groupmultiselect
  • image — JPEG, PNG, GIF, WebP; 2 MB max

Each field accepts name, label, placeholder, defaultValue, and a validation object with required, minLength, maxLength, pattern, min, max.

Handling submission

Form submissions flow through your handler with the same (args, user)signature as custom actions. Whatever the handler returns is fed back to the agent as the form’s result. Optionally configure a webhook destination in the dashboard so the data also flows server-side.

Related