Feedback
Collect visitor feedback with a form configured in the dashboard.
Quick start
Mount the form into an element
const form = await window.Portal.feedback.mount('#feedback', { reference_num: 'FEEDBACK_REF', display: 'inline' });
if (form !== null) {
form.open();
}API reference
form
The handle Portal.feedback.mount() returns, to control the mounted form.
close()
Hides the form again.
form.close();destroy()
Removes the form and everything it added to the page.
form.destroy();open()
Shows the form (for the button, dialog and accordion displays).
form.open();window.Portal.feedback
Portal.feedback — collect visitor feedback with a form configured in the dashboard.
config()
Reads a feedback form's configuration.
const feedbackConfigResponse = await window.Portal.feedback.config(referenceNum);Parameters
| Name | Type | Required | Description |
|---|---|---|---|
referenceNum | string | Yes | The record's reference number. |
Returns
Resolves with a PortalFeedbackConfigResponse: The answer to Portal.feedback.config(): how a feedback form is configured.
mount()
Draws the feedback form into target (a selector or element). Resolves with a handle, or null when the form is unavailable.
const result = await window.Portal.feedback.mount(target, opts);Parameters
| Name | Type | Required | Description |
|---|---|---|---|
target | string | Element | Yes | Draws the feedback form into target (a selector or element). |
opts | PortalFeedbackMountOptions | Yes | Options of Portal.feedback.mount(). |
Returns
Resolves with PortalFeedbackInstance \| null.
open()
Opens a mounted form by its reference (for example from your own button).
window.Portal.feedback.open(referenceNum);Parameters
| Name | Type | Required | Description |
|---|---|---|---|
referenceNum | string | Yes | The record's reference number. |
scan()
Mounts every [data-feedback-kind="form"] element found under root (default: the whole document).
window.Portal.feedback.scan(root);Parameters
| Name | Type | Required | Description |
|---|---|---|---|
root | ParentNode | No | Mounts every [data-feedback-kind="form"] element found under root (default: the whole document). |
submit()
Sends feedback. Fetches an anti-spam token itself when payload.token is missing.
const feedbackSubmitResponse = await window.Portal.feedback.submit(payload);Parameters
| Name | Type | Required | Description |
|---|---|---|---|
payload | PortalFeedbackSubmitPayload | Yes | What Portal.feedback.submit() sends: one piece of visitor feedback for a feedback form. |
Returns
Resolves with a PortalFeedbackSubmitResponse: The answer to Portal.feedback.submit().
token()
Gets a one-time anti-spam token to send with submit().
const value = await window.Portal.feedback.token(referenceNum);Parameters
| Name | Type | Required | Description |
|---|---|---|---|
referenceNum | string | Yes | The record's reference number. |
Returns
Resolves with a string.
Types
PortalFeedbackConfigResponse
The answer to Portal.feedback.config(): how a feedback form is configured.
| Name | Type | Required | Description |
|---|---|---|---|
success | boolean | Yes | True when the form exists and is published. |
reference_num | string | Yes | The form's reference. |
config_version | number | Yes | Increases every time the owner changes the form; use it to cache. |
config | Record<string, unknown> | Yes | The form's configuration (fields, texts, colours). Treat as opaque and pass it to mount({ config }) for previews. |
PortalFeedbackMountOptions
Options of Portal.feedback.mount().
| Name | Type | Required | Description |
|---|---|---|---|
reference_num | string | Yes | The reference of the feedback form to show. |
display | string | No | How the form appears: in the page (inline), behind a floating button, in a dialog, or as an accordion. One of inline, button, dialog, accordion. |
onSubmitted | (r: { reference_num: string }) => void | No | Called after the visitor's feedback was stored. |
config | Record<string, unknown> | No | Draw this configuration instead of fetching it (previews). Nothing is sent. |
PortalFeedbackSubmitPayload
What Portal.feedback.submit() sends: one piece of visitor feedback for a feedback form.
| Name | Type | Required | Description |
|---|---|---|---|
reference_num | string | Yes | The reference of the feedback form (from the dashboard). |
name | string | No | The visitor's name, when the form asks for it. |
email | string | No | The visitor's e-mail, when the form asks for it. |
message | string | No | The feedback text. |
token | string | No | The anti-spam token from Portal.feedback.token(); submit() fetches one itself when it is missing. |
website | string | No | The honeypot: always empty from a person. |
page_url | string | No | The page the feedback was given on; defaults to the current URL in the reference UI. |
locale | string | No | The visitor's language, for example 'en'. |
PortalFeedbackSubmitResponse
The answer to Portal.feedback.submit().
| Name | Type | Required | Description |
|---|---|---|---|
success | boolean | Yes | True when the feedback was stored. |