Skip to main content
A form collector lets an AGO agent fill a form by talking to the user. You define the form’s fields once, as a JSON schema. The JavaScript SDK gives the agent a function to record values as the conversation goes, keeps a live store you can render, and tells the agent which required fields are still missing so it knows what to ask next. From that schema the SDK creates:
  • an observable store holding the collected values and whether the form was submitted; compute completeness (missing, complete) with deriveFormStatus
  • an update_<name> function the agent calls to record values (it can call it many times, with any subset of fields)
  • a context entry sent with every message so the agent always knows the current values and what’s left
  • an optional submit_<name> function that sends the completed form
In the admin interface, open Agents → Advanced → Conversational forms to manage stored form definitions and review their submissions. These forms collect information during a conversation; pre-chat forms and ticket forms are configured separately.

Create a Collector

The name becomes the function names (update_order, submit_order), so it must contain only letters, numbers, underscores, or hyphens, and be at most 40 characters.

Store the form in AGO

Instead of writing the schema in your page, you can store it in AGO and fetch it by name. Change a field in the admin interface and every page picks it up on its next load, without a redeploy. Create the definition in Agents → Advanced → Conversational forms (its name, description, schema and submit target), then reference it by name:
Any option you pass overrides the stored one. Use this for a browser-only submit handler, which cannot be stored in AGO:
A runnable version is in the SDK’s public repository, under examples/simple-html/credit-form-backend.html.

React

useFormCollector registers the collector on mount, removes it on unmount, and returns the live state.
Keep the schema and submit object stable across renders (declare them outside the component or memoize them) so an inline handler isn’t captured stale. To use a form stored in AGO instead, pass only its name — the hook fetches the definition and exposes loading while it does:

State

The store holds only the canonical state: Completeness is derived from the values, not stored. Compute it with deriveFormStatus(schema, values) — or, in React, read it straight off order.state, which already includes it:

Restoring state after a reload

When a visitor reloads the page and you reopen their previous conversation, the collector restores values from recorded update_<name> calls. A completed recorded submit_<name> call also restores submitted: true. Automatic submissions and calls made only through your own UI do not leave that submit tool call, so the conversation history alone cannot restore their submitted state. Check your own submission records before offering another submission in those flows. This happens on its own once the collector is installed (with install or useFormCollector): loading a conversation restores any matching form. Loading a conversation that never used the form leaves it at its initial values. If you build the conversation loading yourself, call order.hydrate(toolCalls) with the tool calls of the loaded messages to restore the state manually.

Submitting

Choose how the completed form is sent with the submit option. With a submit target, autoSubmit defaults to true: the form sends as soon as all required fields are filled, and no submit_<name> function is exposed to the agent. Set autoSubmit: false to wait for an explicit call from the agent or your UI, as in the examples above.
The browser sends the values to a URL you control, using the page’s existing session. Use this when the endpoint is your own API and needs no server-only secret.
With autoSubmit: false, submit_<name> only submits once every required field is present. If fields are still missing it returns them instead, so the agent asks for the rest before trying again. You can also submit from your own UI by calling order.submit().

Submission history

Every form submitted through AGO ({ via: "backend" }) is kept in a history you can review in the admin interface. Open Agents → Advanced → Conversational forms and click Form Submissions to see, for each submission:
  • the date and time it was sent
  • the form it belongs to
  • whether it is in progress, completed, or failed
  • the user who submitted it
  • a preview of the submitted values
Click a row to open its detail page, with the full submitted data and the failure reason if it failed. Filter the list by form, status, or date range. Submissions sent from the browser ({ via: "client" }) do not go through AGO, so they don’t appear here.

Forms still being filled

While the agent collects a form stored in Agents → Advanced → Conversational forms during a conversation, the history also shows it as In progress, with the values collected so far and the time of the last change. A conversation that ends before the form is sent still shows what was collected. When the form is sent, that entry becomes the submission, with the submitted values. Each conversation has at most one in-progress entry per form, and nothing new is recorded for a form once the conversation has sent it. In-progress values are for your review only: the agent never reads them back. From @useago/sdk 1.16.0, a form submitted during a conversation is linked to that conversation. To read submissions from your own systems, with the conversation each one came from, use GET /api/v1/form-submissions of the Public API. Submissions sent before that version are not linked to a conversation.

Complete Example

A contact-intake form in plain JavaScript. The agent collects the prospect’s details through the conversation, the summary updates live, and the form submits once it’s complete.
A runnable version is in the SDK’s public repository, under examples/simple-html/contact-form.html.