Skip to content

Feedback ​

Collect visitor feedback with a form configured in the dashboard.

Quick start ​

Mount the form into an element

ts
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.

ts
form.close();

destroy() ​

Removes the form and everything it added to the page.

ts
form.destroy();

open() ​

Shows the form (for the button, dialog and accordion displays).

ts
form.open();

window.Portal.feedback ​

Portal.feedback — collect visitor feedback with a form configured in the dashboard.

config() ​

Reads a feedback form's configuration.

ts
const feedbackConfigResponse = await window.Portal.feedback.config(referenceNum);

Parameters

NameTypeRequiredDescription
referenceNumstringYesThe 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.

ts
const result = await window.Portal.feedback.mount(target, opts);

Parameters

NameTypeRequiredDescription
targetstring | ElementYesDraws the feedback form into target (a selector or element).
optsPortalFeedbackMountOptionsYesOptions of Portal.feedback.mount().

Returns

Resolves with PortalFeedbackInstance \| null.

open() ​

Opens a mounted form by its reference (for example from your own button).

ts
window.Portal.feedback.open(referenceNum);

Parameters

NameTypeRequiredDescription
referenceNumstringYesThe record's reference number.

scan() ​

Mounts every [data-feedback-kind="form"] element found under root (default: the whole document).

ts
window.Portal.feedback.scan(root);

Parameters

NameTypeRequiredDescription
rootParentNodeNoMounts 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.

ts
const feedbackSubmitResponse = await window.Portal.feedback.submit(payload);

Parameters

NameTypeRequiredDescription
payloadPortalFeedbackSubmitPayloadYesWhat 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().

ts
const value = await window.Portal.feedback.token(referenceNum);

Parameters

NameTypeRequiredDescription
referenceNumstringYesThe record's reference number.

Returns

Resolves with a string.

Types ​

PortalFeedbackConfigResponse ​

The answer to Portal.feedback.config(): how a feedback form is configured.

NameTypeRequiredDescription
successbooleanYesTrue when the form exists and is published.
reference_numstringYesThe form's reference.
config_versionnumberYesIncreases every time the owner changes the form; use it to cache.
configRecord<string, unknown>YesThe form's configuration (fields, texts, colours). Treat as opaque and pass it to mount({ config }) for previews.

PortalFeedbackMountOptions ​

Options of Portal.feedback.mount().

NameTypeRequiredDescription
reference_numstringYesThe reference of the feedback form to show.
displaystringNoHow 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 }) => voidNoCalled after the visitor's feedback was stored.
configRecord<string, unknown>NoDraw 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.

NameTypeRequiredDescription
reference_numstringYesThe reference of the feedback form (from the dashboard).
namestringNoThe visitor's name, when the form asks for it.
emailstringNoThe visitor's e-mail, when the form asks for it.
messagestringNoThe feedback text.
tokenstringNoThe anti-spam token from Portal.feedback.token(); submit() fetches one itself when it is missing.
websitestringNoThe honeypot: always empty from a person.
page_urlstringNoThe page the feedback was given on; defaults to the current URL in the reference UI.
localestringNoThe visitor's language, for example 'en'.

PortalFeedbackSubmitResponse ​

The answer to Portal.feedback.submit().

NameTypeRequiredDescription
successbooleanYesTrue when the feedback was stored.