Widget Embedding
Overview
The PromethistAI Widget allows you to embed Relational Agents directly into your website with a single script tag. The widget can appear as a floating assistant that users expand to interact with your agent, or it can be mounted into a container element you control.
Quick Start
Add one script tag and provide either data-region or data-url.
<script
src="https://eu.promethist.ai/client/embedding/promethist-widget.js"
data-region="eu"
data-agent-ref="agent:yourAgentRef"></script>
|
Replace yourAgentRef with your agent’s unique identifier. To find it, use the Copy URL option and take the part at the end of the URL, after /a/. For example, in https://eu.promethist.ai/a/myAgentQsiqmy.0 the agent reference is myAgentQsiqmy.0. Plain values are normalized to the agent:… form automatically.
Using Draft Agents
If your agent is not published and still in draft status, append the draft number to the agent reference:
<!-- For Draft-0 -->
<script
src="https://eu.promethist.ai/client/embedding/promethist-widget.js"
data-region="eu"
data-agent-ref="agent:yourAgentRef.0"></script>
<!-- For Draft-1 -->
<script
src="https://eu.promethist.ai/client/embedding/promethist-widget.js"
data-region="eu"
data-agent-ref="agent:yourAgentRef.1"></script>
|
Setup Patterns
Use one of the following setup patterns based on how much control you need.
Hosted by Region
<script
src="https://eu.promethist.ai/client/embedding/promethist-widget.js"
data-region="eu"
data-agent-ref="agent:yourAgentRef"></script>
Custom URL
<script
src="https://eu.promethist.ai/client/embedding/promethist-widget.js"
data-url="https://eu.promethist.ai/client/?isEmbedded=true&key=agent%3AyourAgentRef"></script>
|
The URL must resolve to a valid absolute, non-opaque origin (for example, |
Global Config Object
For more control, set configuration globally before loading the script:
<script>
window.PromethistWidgetConfig = {
// region is required only when url is not set
region: 'eu',
// url: 'https://eu.promethist.ai/client/?isEmbedded=true&key=agent%3AyourAgentRef',
agentRef: 'agent:yourAgentRef',
showExpanded: false,
showOnReady: true,
autoInit: true
};
</script>
<script src="https://eu.promethist.ai/client/embedding/promethist-widget.js"></script>
This approach is useful when you need to:
-
Dynamically generate configuration values
-
Integrate with existing JavaScript frameworks
-
Apply conditional logic to widget settings
Container Layout
Mount the widget into an element you control instead of floating it:
<div id="assistant-container" style="position: relative; width: 100%; height: 500px;"></div>
<script
src="https://eu.promethist.ai/client/embedding/promethist-widget.js"
data-region="eu"
data-layout-mode="container"
data-container="#assistant-container"></script>
Configuration Reference
All supported configuration keys and their corresponding script attributes.
| Config key | Script attribute | Default | Notes |
|---|---|---|---|
|
|
|
Required when |
|
|
|
If set, it is used directly and |
|
|
|
Plain values are normalized to |
|
|
|
Floating mode display preference. |
|
|
|
If |
|
|
|
Positive integer. |
|
|
|
Positive integer. |
|
|
|
Allowed: |
|
|
|
Floating collapsed dimensions. |
|
|
|
Floating expanded dimensions. |
|
|
|
Floating collapsed position. |
|
|
|
Floating expanded position. |
|
|
|
Applied as a CSS variable. |
|
|
|
Controls iframe |
|
|
|
Controls iframe |
|
|
|
If |
|
|
|
Only meaningful for floating mode first-open behavior. |
|
|
|
Allowed: |
|
|
|
Required when |
|
Boolean parsing rule: any provided value except the literal |
JavaScript API
|
Initialization rule: default-instance methods do not auto-create an instance. Call |
Static API
// Properties
PromethistWidget.version;
PromethistWidget.state;
PromethistWidget.instances;
// Methods
const widget = PromethistWidget.create({ region: 'eu', agentRef: 'agent:demo' });
const sameWidget = PromethistWidget.getInstance(widget.id);
PromethistWidget.init(overrides?);
PromethistWidget.open({ skipCollapsedOnFirstOpen?: boolean }?);
PromethistWidget.show({ expanded?: boolean }?);
PromethistWidget.setAgentRef('agent:anotherRef');
PromethistWidget.setAgentRef({ agentRef: 'agent:anotherRef' });
PromethistWidget.setExpanded(true);
PromethistWidget.expand();
PromethistWidget.collapse();
PromethistWidget.hide();
PromethistWidget.destroy();
PromethistWidget.clear();
const off = PromethistWidget.on('promethist:ready', (event) => {
console.log(event.detail.instanceId);
});
off();
Instance API
const widget = PromethistWidget.create({
region: 'eu',
agentRef: 'agent:yourAgentRef',
autoInit: false
});
widget.id;
widget.state;
widget.config;
widget.init({ showOnReady: false });
widget.open({ skipCollapsedOnFirstOpen: true });
widget.show({ expanded: true });
widget.setAgentRef('agent:newAgentRef');
widget.setExpanded(true);
widget.expand();
widget.collapse();
widget.hide();
widget.destroy();
widget.clear();
widget.on('promethist:warning', (event) => console.warn(event.detail.code));
|
Layout caveat: |
Events, Warning Codes, and States
All events are dispatched on document.
| Event | Detail payload | When emitted |
|---|---|---|
|
|
Iframe reports widget ready. |
|
|
Widget opens to expanded scene. |
|
|
Widget is hidden. |
|
|
Widget instance is destroyed. |
|
|
Internal state transition. |
|
|
Capability mismatches, timeouts, or invalid transitions. |
Lifecycle and No-op Rules
The typical lifecycle is:
create() -> init() -> show()/open()/setExpanded() -> hide()/collapse() -> destroy()
-
init(): only works inidle; no-op otherwise. -
open(): works incollapsed/hidden; queues whileloading. -
show(): no-op if iframe is not initialized. In floating mode, may collapse or open expanded based on config/options. -
hide(): no-op if iframe is not initialized; transitions tohidden. -
setExpanded(true): floating mode only, routed throughopen(). -
setExpanded(false): floating mode only, requests collapsed icon state. -
setAgentRef(): queues whileloading, updates live incollapsed/expanded/hidden. -
destroy(): always removes the iframe and transitions todestroyed.
Technical Requirements
The widget inherits the same technical requirements as the Web Client:
-
WebGPU support in the browser
-
Microphone permissions for voice interaction
-
Modern browser (Chrome, Edge, Safari with WebGPU)
See Web Client Technical Requirements for detailed browser compatibility information.
Troubleshooting
Widget Not Appearing
Check the browser console for errors. Common issues include:
-
Missing
data-region(ordata-url) — one of them is required -
Invalid agent reference (verify you’re using the correct format for draft agents)
-
showOnReadyset tofalsewithout a subsequent explicitshow()/open()call -
autoInitset tofalsewithout callinginit()yourself -
WebGPU not supported by the browser
-
JavaScript errors blocking widget initialization