Skip to content

Install the widget

There are two ways to install the Patchrooms widget. Use the loader for a plain one-liner; use programmatic init when you need to pass options in code.

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

Swap pr_xxx for your project key and drop the tag into your page.

The server bakes your project’s widget config (mascot, shape, anchor, offsets, size, trigger style) and its channels into the loader it serves for your key. So the widget renders with the right theme and channels straight away — no extra request for config, and no flash of an unstyled launcher. It auto-initializes; you don’t call anything.

Programmatic init (SPAs and custom config)

Section titled “Programmatic init (SPAs and custom config)”

Load the shared bundle, then call Patchrooms.init(...) yourself. Use this when you want to pass options that aren’t baked into the loader — a userId, extra context, a different locale, and so on — or to control the widget’s lifecycle in a single-page app.

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

If you embed the shared bundle directly, the widget can also configure itself from data-* attributes on its own <script> tag — no inline init() call needed:

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

Only these attributes are read from the script tag:

AttributeMaps toNotes
data-project-keyprojectKeyYour public pr_ key.
data-api-urlapiUrlOverride the ingest base URL (rarely needed).
data-localelocaleen or ru.

These are the options accepted by Patchrooms.init({ ... }).

OptionTypeDefaultDescription
projectKeystring (required)Public project key from the dashboard.
locale'en' | 'ru'auto-detect from navigator.languageWidget UI language.
apiUrlstringthe widget script’s originIngest 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 JavaScript widget for the set.
shapeShapeId'bubble'Container shape glued to the viewport edge.
anchorWidgetAnchor'middle-right'Anchor corner/edge of the viewport.
triggerVariant'frame-tab' | 'devwidget''frame-tab'Trigger launcher style.
sizenumber44Trigger size in px (square), clamped to 32–64.
offsetXnumber0Horizontal offset from the anchor in px (positive = inward).
offsetYnumber0Vertical offset from the anchor in px (positive = inward).
widgetIdstringauto-generatedUnique 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).
pushToTalkKeystringHotkey (KeyboardEvent.key) for push-to-talk audio capture while open.