Passing HubSpot Form Submissions to Docket
Last updated: August 11, 2026
Pass selected HubSpot form values to a Marketing Agent after a successful submission, then open the widget with that context.
Before You Begin
Install the HubSpot form and Docket widget on the same page.
Configure the matching fields under Agent > Dynamic Context Ingestion.
Determine whether the form uses HubSpot's updated forms editor or a legacy form.
If the form redirects after submission, run the Docket flow on the destination page or remove the redirect so the widget has time to open.
Updated HubSpot Forms
Updated forms emit hs-form-event:on-submission:success. Use HubSpotFormsV4.getFormFromEvent() to retrieve the submitted form instance and read the fields you need.
window.addEventListener("hs-form-event:on-submission:success", async (event) => {
if (!window.HubSpotFormsV4 || !window.AISeller?.setContext) {
return;
}
const form = window.HubSpotFormsV4.getFormFromEvent(event);
const [firstName, email, company] = await Promise.all([
form.getFieldValue("0-1/firstname"),
form.getFieldValue("0-1/email"),
form.getFieldValue("0-1/company")
]);
const result = await window.AISeller.setContext({
name: String(firstName || ""),
email: String(email || ""),
company: String(company || "")
});
if (result.success) {
window.AISeller.showAndConnect();
} else {
console.warn(result.message);
}
});HubSpot field identifiers can vary. Use the actual field names from your form. Multi-checkbox fields can return arrays, which must be converted to a supported simple value before calling setContext().
Legacy HubSpot Forms
Legacy forms can emit an hsFormCallback window message after the submission is persisted.
window.addEventListener("message", async (event) => {
const data = event.data;
if (data?.type !== "hsFormCallback" || data.eventName !== "onFormSubmitted") {
return;
}
if (!window.AISeller?.setContext || !window.AISeller?.showAndConnect) {
return;
}
const fields = data.data?.submissionValues || {};
const result = await window.AISeller.setContext({
name: String(fields.firstname || ""),
email: String(fields.email || ""),
company: String(fields.company || "")
});
if (result.success) {
window.AISeller.showAndConnect();
} else {
console.warn(result.message);
}
});HubSpot form events are non-blocking. Do not assume the event will delay a configured page redirect.
Verify the Flow
Open the page in a private browser window.
Submit the HubSpot form with documentation-only values.
Confirm the correct HubSpot success event fires.
Confirm
setContext()returnssuccess: true.Confirm the widget opens and starts the conversation.
Verify the agent uses the selected fields according to their Dynamic Context descriptions.
Test the form's redirect or thank-you behavior.
Troubleshooting
Problem | What to check |
|---|---|
The listener never runs | Confirm whether the form is updated or legacy and use the matching event API. |
Field values are empty | Inspect the form's actual field identifiers and map those names. |
| Convert array or complex HubSpot values into strings, numbers, booleans, or |
The page redirects before the widget opens | Remove the redirect or continue the Docket flow on the destination page. |
The form submits more than once on the page | Use the event's form and instance IDs to limit the handler to the intended form. |
Old values appear in another session | Call |