Skip to content

JavaScript widget

The Patchrooms widget is a small browser script that docks a feedback room to the edge of your app. It ships as a global Patchrooms object once loaded.

There are two ways to load it.

Drop one script tag into your page. The URL carries your project key, and the server returns a tiny loader with your widget configuration and channels baked in — the room renders themed immediately and initializes itself.

<script src="https://room.patchrooms.com/v1/patchrooms/pr_xxx.js"></script>

Replace pr_xxx with your public project key from the dashboard. No Patchrooms.init() call is needed — the loader auto-initializes.

Load the shared bundle and call init() yourself. Use this when you need to control timing (for example, a single-page app that re-parents the widget between routes).

<script src="https://room.patchrooms.com/v1/patchrooms.js"></script>
<script>Patchrooms.init({ projectKey: 'pr_xxx' });</script>

Initializes the widget and mounts it. init() is idempotent — calling it again tears the widget down and rebuilds it with the new options. projectKey is the only required field (except in local storage mode).

Patchrooms.init({
projectKey: 'pr_xxx',
locale: 'en',
anchor: 'bottom-right',
});
OptionTypeDefaultDescription
projectKeystringPublic project key from the dashboard. Required (except in local storage mode).
locale'en' | 'ru'auto-detectWidget UI language. Falls back to navigator.language.
apiUrlstringscript origin, else https://room.patchrooms.comIngest API base URL.
userIdstringOptional user identifier, forwarded with every report.
extraRecord<string, unknown>Extra fields attached to context.extra on every submission.
captureConsoleErrorsbooleantrueHook console.error so the last 10 errors auto-attach to reports.
mascotMascotId'fox'Mascot character. See mascots.
shapeShapeId'bubble'Container shape glued to the viewport edge. See shapes.
anchorWidgetAnchor'middle-right'Anchor corner/edge of the viewport. See anchors.
triggerVariant'frame-tab' | 'devwidget''frame-tab'Trigger launcher style.
sizenumber44Trigger size in px (square shell), clamped to 32–64.
offsetXnumber0Horizontal offset from the anchor in px (positive = inward).
offsetYnumber0Vertical offset from the anchor in px (positive = inward).
widgetIdstringautoUnique id for cross-widget collision avoidance.
attributesRecord<string, unknown>Initial host attributes, copied into custom.* at init time.
onChannelChange(next, prev) => voidCalled whenever the active channel changes (including to null). Each argument is { key: string } | null.
pushToTalkKeystringKeyboardEvent.key for push-to-talk audio capture while the panel is open. Opt-in.
mode'default' | 'artifact-review''default'Operating mode. artifact-review attaches artifact metadata to reports.
artifactArtifactMetaArtifact under review (used in artifact-review mode).
storage'cloud' | 'local''cloud'Where reports are stored. local keeps everything in localStorage with no network calls.

gecko · owl · fox · cat · axolotl · raccoon · chameleon · otter · robot · blob

frame-tab · bubble · tab · pill · blob

top-left · top-center · top-right · middle-left · middle-right · bottom-left · bottom-center · bottom-right

All methods below are properties of the global Patchrooms object. Except for init() and destroy(), they throw if the widget has not been initialized.

Files a one-shot report programmatically. The message becomes a single text block in the active channel. Returns a Promise that rejects if the submission fails.

await Patchrooms.report({
message: 'Checkout button is misaligned on mobile',
extra: { route: '/checkout' },
});
OptionTypeDescription
messagestringReport text. Becomes a single text block.
extraRecord<string, unknown>Merged into context.extra for this report.

Checks whether an alpha feature flag is enabled for the current user and, if so, marks it on the widget. Returns a Promise<boolean>.

const enabled = await Patchrooms.alpha('new-dashboard');

Shows the widget.

Hides the widget.

Opens the report panel programmatically.

Tears down the widget and clears SDK state. Safe to call when not initialized — it becomes a no-op. After destroy() the SDK can be re-initialized with a different projectKey or apiUrl.

Sets a single attribute on the channel engine. Attributes feed channel matching.

Patchrooms.setAttribute('custom.plan', 'pro');

Sets multiple attributes at once.

Patchrooms.setAttributes({ 'custom.plan': 'pro', 'custom.role': 'admin' });

Forces the active channel. The optional weight (number | 'max' | 'suggest') controls how strongly the override applies.

Patchrooms.setChannel('bug', { weight: 'max' });

Clears a manual channel override and lets automatic matching resume.

Returns the currently active channel (or null).

Returns the list of channels currently known to the widget.