- an observable store holding the collected
valuesand whether the form wassubmitted; compute completeness (missing,complete) withderiveFormStatus - 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
Create a Collector
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:handler, which cannot be stored in AGO:
examples/simple-html/credit-form-backend.html.
React
useFormCollector registers the collector on mount, removes it on unmount, and returns the live state.
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 recordedupdate_<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 thesubmit 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.
- From the browser
- Through AGO
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.
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
{ 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.examples/simple-html/contact-form.html.
Related Documentation
- Client Functions — the lower-level browser functions this builds on
- JavaScript SDK — full SDK setup and usage
- SDK API Reference — REST endpoints used by the SDK
