Passing Form Data to a Marketing Agent
Last updated: August 11, 2026
Pass selected form values to Docket before opening the widget so the agent can continue the visitor's journey without asking for the same information again.
Before You Begin
Install the Docket widget script on the page.
Configure the corresponding fields under Agent > Dynamic Context Ingestion.
Decide which submitted values the agent actually needs.
Do not send passwords, tokens, payment details, or other sensitive form values.
Configure the Variables
Open the agent's Agent tab.
Expand Dynamic Context Ingestion.
Enable the feature and add each form field the agent should use.
Give each variable a clear description.
Pass Selected Form Fields
Map the fields explicitly. Do not pass the complete FormData object because file inputs and unsupported values can cause validation to fail.
<form id="demo-request">
<input name="name" autocomplete="name" required />
<input name="email" type="email" autocomplete="email" required />
<input name="company" autocomplete="organization" />
<button type="submit">Talk to Sales</button>
</form>
<script>
document.getElementById("demo-request").addEventListener("submit", async (event) => {
event.preventDefault();
if (!window.AISeller?.setContext || !window.AISeller?.showAndConnect) {
console.warn("The Docket widget is not ready.");
return;
}
const form = new FormData(event.currentTarget);
const result = await window.AISeller.setContext({
name: String(form.get("name") || ""),
email: String(form.get("email") || ""),
company: String(form.get("company") || "")
});
if (!result.success) {
console.warn("Docket context was not stored:", result.message);
return;
}
window.AISeller.showAndConnect();
});
</script>The widget accepts flat values that are strings, numbers, booleans, or null. Nested objects, arrays, files, functions, dates, and undefined values are rejected.
Reset Context When Identity Changes
Call resetContext() when a visitor logs out or when another person may use the same browser session.
await window.AISeller.resetContext();Verify the Form Flow
Open the page in a private browser window.
Submit the form with documentation-only values.
Confirm
setContext()returnssuccess: true.Confirm the widget opens and starts the conversation.
Verify the agent uses the submitted values according to the configured variable descriptions.
Reset context and confirm a new conversation does not reuse the previous visitor's values.
Troubleshooting
Problem | What to check |
|---|---|
The form submits but the widget does not open | Confirm |
| Read |
The agent ignores a field | Confirm the JavaScript key matches a configured Dynamic Context variable. |
The page navigates away before context is stored | Call |
Another visitor's values appear | Call |