Jarabot Widget SDK
Embed the Jarabot chat widget on any website and drive it from JavaScript — pass user context, send messages, attach custom attributes, and react to conversation events.
Install the widget
Drop the snippet below right before the closing
</body> tag of any page where the widget should
appear. Replace <WEBSITE_TOKEN> with the token from
your inbox settings and <URL> with your Jarabot
installation URL.
<script>
window.jarabotSettings = {
"locale": null,
"baseDomain": null,
"useBrowserLanguage": false,
"hideMessageBubble": false,
"position": "right",
"type": "standard",
"launcherTitle": "Četujte s nami",
"welcomeTitle": null,
"welcomeTagline": null,
"showPopoutButton": false,
"showUnreadMessagesDialog": true,
"unreadMessagesMaxHeight": null,
"widgetStyle": "standard",
"darkMode": "light",
"widgetOffsetX": null,
"widgetOffsetY": null,
"userMessageColor": null,
"productButtonColor": null,
"productButtonLabel": null,
"backButton": true,
"closeButton": true,
"fontFamily": null,
"fontStylesheetUrl": null,
"baseFontSize": null,
"backgroundGradient": null,
"backgroundTextColor": null,
"backgroundButtonColor": null,
"backgroundButtonTextColor": null,
"sendGAEvents": true
};
(function(d, t) {
var BASE_URL = '<URL>';
var g = d.createElement(t), s = d.getElementsByTagName(t)[0];
g.src = BASE_URL + '/packs/js/sdk.js';
g.defer = true;
g.async = true;
s.parentNode.insertBefore(g, s);
g.onload = function() {
window.jarabotSDK.run({
websiteToken: '<WEBSITE_TOKEN>',
baseUrl: BASE_URL
});
};
})(document, 'script');
</script>
Embed the chat in a page
By default the widget is a bubble in the corner of the page that opens
the chat window. To show the chat inside the page instead, for example
in a section of a contact or advice page, put an empty element where
the chat goes and name it in embedContainer. The chat
fills that element, is open from the start and has no bubble.
<div id="jarabot-chat" style="height: 600px"></div>
<script>
window.jarabotSettings = {
"locale": "cs",
"embedContainer": "#jarabot-chat"
};
(function(d, t) {
var BASE_URL = '<URL>';
var g = d.createElement(t), s = d.getElementsByTagName(t)[0];
g.src = BASE_URL + '/packs/js/sdk.js';
g.defer = true;
g.async = true;
s.parentNode.insertBefore(g, s);
g.onload = function() {
window.jarabotSDK.run({
websiteToken: '<WEBSITE_TOKEN>',
baseUrl: BASE_URL
});
};
})(document, 'script');
</script>
-
Give the element a height, such as
height: 600pxorheight: 70vh: the chat takes its full width and height. Leave the element empty. -
embedContaineris a CSS selector ("#jarabot-chat","[data-chat]") or the element itself. The snippet can stand above or below the element. If the element is not on the page, no chat is shown at all and the browser console says so. A page that renders the element later from JavaScript callsjarabotSDK.run()once the element is there. Only a missing ornullvalue gives the bubble, sodocument.querySelector()of an element that is not on the page gives the bubble too: pass the selector itself for no chat there. -
On a site that changes pages without reloading them (Turbo,
Astro), use a selector. Once the chat has started, it moves into
the element of each new page, and a page without one has no chat.
If the first page the visitor opens has no element, the chat does
not start there: a later page that has the element calls
jarabotSDK.run({ websiteToken, baseUrl })once it is rendered. To switch between the embedded chat and the bubble, the site loads the page in full. - When the website inbox's widget is switched off, the element stays empty.
-
There is one widget per page. To have the bubble on the other
pages of the site, put the usual snippet there, without
embedContainer. -
The embedded chat has no bubble and no close (×) button, and
Esc does not close it, so it needs no
closeButton: false. A reply shows in the chat, there is no unread messages preview. -
To give the chat the font of your page and a bigger text, add
fontFamily,fontStylesheetUrlandbaseFontSize: the chat does not get the fonts your page loads. -
The bubble settings have no effect:
position,type,launcherTitle,hideMessageBubble,widgetOffsetX,widgetOffsetY,showUnreadMessagesDialogandunreadMessagesMaxHeight. -
To match the colors of the page, a
backgroundGradientreplaces the grey background of the chat; for a dark gradient setbackgroundTextColortoo, andbackgroundButtonColorwhen the buttons blend into it. -
toggle()andtoggleBubbleVisibility()do nothing; the other methods work as usual.jarabot:openedfires once, when the chat has loaded (past the robot check, when the visitor gets one), andjarabot:closednever fires. The chat counts as opened each time it loads, past the robot check when the visitor gets one: thewebwidget_triggeredwebhook event (and your bot) and thejarabot_chat_openGoogle Analytics event come on every page view, and again on the same page afterreset()or a page swap that loads the frame again (Turbo shows a cached preview, then the page). -
No CSS or script of your own is needed to move the widget into the
page or to size it. Remove such code (rules for
.woot-widget-holderor#chatwoot_live_chat_widget, a script that moves them or callstoggle('open')).
Send a message
Programmatically post a message into the active conversation on the visitor's behalf — exactly as if they had typed it and hit send. Use it to drive the chat from your page based on what the visitor is doing — for example, when they get stuck on an SMS verification step.
Wait for the jarabot:ready event before calling any SDK
method:
window.addEventListener('jarabot:ready', function () {
window.$jarabot.sendMessage({
message: "Do you need help with entering SMS?",
detail_info: {
step: "sms_verification",
user_name: "Matt Newman",
attempts: 3,
available_actions: [
{ action: "resend_sms", label: "Re-send SMS" },
{ action: "try_other_method", label: "Try different method" }
]
}
});
});
message is the text that gets sent to the server, just
like a normal typed message. detail_info is an optional
structured context payload delivered alongside the message so the
agent / bot has whatever it needs to help the user immediately.
jarabotSettings reference
Define window.jarabotSettings
before calling jarabotSDK.run(). All
keys are optional.
| Key | Type | Default | Description |
|---|---|---|---|
locale |
string | null |
Force a UI language (e.g. "en", "cs",
"sk"). When null, the inbox default is
used.
|
useBrowserLanguage |
boolean | false |
If true, the widget picks up
navigator.language automatically.
|
baseDomain |
string | null |
Domain used for the conversation cookie. Set this to share a
session across subdomains, e.g. ".example.com".
|
embedContainer |
string (CSS selector) | element | null |
Show the chat inside this element of the page instead of the bubble. See Embed the chat in a page. |
position |
"left" | "right" |
"right" |
Bubble placement. |
type |
"standard" | "expanded_bubble"
|
"standard" |
Standard round bubble or expanded bubble with a label. |
launcherTitle |
string | "" |
Label shown next to the bubble when type is
"expanded_bubble".
|
welcomeTitle |
string | null |
Overrides the welcome heading shown in the expanded widget header. Optional — when empty or not defined, the title configured in the inbox settings is used. |
welcomeTagline |
string | null |
Overrides the welcome tagline shown below the heading in the
expanded widget header. Optional — when empty or not defined,
the tagline configured in the inbox settings is used. The
tagline is rendered as Markdown: **bold**,
*italic* and [text](https://…) links
are formatted, bare URLs become links, and links open in a new
tab. HTML is not interpreted and is shown as plain text. The
inbox settings tagline is rendered the same way.
|
hideMessageBubble |
boolean | false |
Hide the bubble entirely. Useful when you launch the widget from
a custom button via toggle().
|
showPopoutButton |
boolean | false |
Show the “open in popout window” button in the widget header. |
showUnreadMessagesDialog |
boolean | true |
Show the unread messages preview above the bubble. |
unreadMessagesMaxHeight |
number | null |
Maximum height (in px) of the unread messages preview above the
bubble. When null, the preview grows with its
content (default behaviour); when set, it is capped to this
height and scrolls.
|
widgetStyle |
"standard" | "flat" |
"standard" |
Rounded card vs flat panel. |
darkMode |
"light" | "auto" |
"light" |
"auto" follows the visitor's OS preference. |
widgetOffsetX |
number | string | null |
Horizontal offset for the bubble (px). Use to clear other floating elements. |
widgetOffsetY |
number | string | null |
Vertical offset for the bubble (px). |
userMessageColor |
string (CSS color) | null |
Overrides the visitor message bubble color. |
productButtonColor |
string (CSS color) | null |
Color for product CTA buttons inside the widget. |
productButtonLabel |
string | null |
Custom label for product CTA buttons. |
backButton |
boolean | true |
Whether the in-widget back button is shown. |
closeButton |
boolean | true |
false keeps the chat open: the close button in the
widget header is hidden, and neither Esc, the bubble nor the
unread messages preview closes the chat. Use it only for a chat placed in the page itself; in a
floating bubble the visitor could not close the chat, and on a
phone it covers the whole screen. Your page can still close it
with toggle('close').
A chat shown with embedContainer
is always open and does not need it.
|
fontFamily |
string (CSS font-family) | null |
Font of the chat and of the bubble's launcher title, e.g.
"'Poppins Natios', Poppins, sans-serif". The chat
runs on its own domain, so it does not get the fonts your page
loads: a font that is not on the visitor's device needs
fontStylesheetUrl too. The launcher title is on
your page and uses your page's fonts.
|
fontStylesheetUrl |
string (https URL) | null |
A CSS file with the @font-face rules of your font,
which the chat loads, e.g.
"https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap".
Give it only @font-face rules: any other rule
would restyle the chat too. Font files on another domain must
allow loading from other websites
(Access-Control-Allow-Origin); Google Fonts does.
The visitor's browser downloads the fonts from that server.
Only https URLs are used.
|
baseFontSize |
number (px, 14–18) | null (14) |
Size of the message text. The rest of the chat (headings,
buttons, icons, spacing) grows with it, e.g. 16
makes the whole chat about 14 % bigger. A value outside
14–18 is ignored: smaller, iOS would zoom the page in on
the reply box; bigger, the chat header no longer fits on a
phone.
|
backgroundGradient |
string (CSS gradient) | null |
A CSS gradient in place of the widget's grey background, e.g.
"linear-gradient(135deg, #004cb8, #051461)".
linear-, radial- and
conic-gradient() (also repeating-)
are accepted, with colors and CSS math (calc(),
sin(), …) inside. An
image (url(), image-set()), a
var(), light-dark(), a system color
(Canvas, …) or any other value is ignored and the grey stays (the browser console says
so). The header bar, message bubbles, cards and the message
input keep their colors (light or dark mode, the widget and
user message colors), and so do the buttons on it unless
backgroundButtonColor is set. For a dark gradient
set backgroundTextColor too. The popped out chat
window keeps the default look.
|
backgroundTextColor |
string (CSS color) | null |
Color of the texts and icons that sit right on the widget
background: the welcome title and tagline with their icons,
date separators, the agent name above messages, the pre-chat
form text and labels, the retry icon of a message that failed
to send, the e-mail transcript button and "Powered by". Unset,
they keep their default colors. Texts in bubbles and cards are not
changed. A color value or color function, no
var() (the page's variables do not reach the
widget), no light-dark() and no system colors
(CanvasText, …). Dark mode has light
default texts, so a light gradient with darkMode
"dark" or "auto" needs this too. Used
only together with a backgroundGradient the widget
accepts: on the grey a light color would hide the texts.
|
backgroundButtonColor |
string (CSS color) | null |
Background of the buttons that sit right on the widget
background: "Start Conversation" under the pre-chat form and
"Start a new conversation" under a resolved conversation.
Unset, they have the widget color, which blends into a
gradient of the same color. E.g. "#fff" with
backgroundButtonTextColor "#004cb8".
The same values as backgroundTextColor, and also
used only together with a backgroundGradient the
widget accepts.
|
backgroundButtonTextColor |
string (CSS color) | null |
Text color of the same buttons. Unset, it stays white or black,
whichever reads better on the widget color, so with a light
backgroundButtonColor set this too. The same
values as backgroundTextColor, and also used only
together with a backgroundGradient the widget
accepts.
|
sendGAEvents |
boolean | true |
Push widget interaction events to
window.dataLayer / gtag. Enabled by
default; set to false to opt out. See
Google Analytics events for the full
list.
|
jarabotSDK.run()
Starts the widget. Call this once, after the SDK script has loaded.
window.jarabotSDK.run({
websiteToken: '<WEBSITE_TOKEN>',
baseUrl: 'https://your-jarabot-host.example.com'
});
| Parameter | Type | Required | Description |
|---|---|---|---|
websiteToken |
string | yes | The token of the website inbox you want to connect to. |
baseUrl |
string | yes | The base URL of your Jarabot installation. |
run() a second time is a no-op once the widget
has booted. If you need to switch user identity at runtime, call
reset() first.
Google Analytics events
By default (jarabotSettings.sendGAEvents is
true unless set to false), the widget pushes
events to window.dataLayer (GTM) or calls
gtag('event', ...) if available. Use these to track
widget engagement in GA4 or any other tag manager that listens to the
data layer.
| Event | Trigger | dataLayer payload |
|---|---|---|
jarabot_widget_ready |
Widget loaded | { event: 'jarabot_widget_ready' } |
jarabot_chat_open |
User opens chat. A chat
embedded in the page sends it each time
the chat loads, past the robot check when the visitor gets
one: on every page view, and again after reset()
or a page swap that reloads the frame.
|
{ event: 'jarabot_chat_open' } |
jarabot_chat_close |
User closes chat | { event: 'jarabot_chat_close' } |
jarabot_message_sent |
User sends message | { event: 'jarabot_message_sent' } |
jarabot_message_received |
Bot/agent responds |
{ event: 'jarabot_message_received', sender_type: 'bot'
}
|
jarabot_conversation_started |
New conversation | { event: 'jarabot_conversation_started' } |
jarabot_campaign_shown |
Static campaign popup shown | { event: 'jarabot_campaign_show' } |
jarabot_campaign_click |
Static campaign popup clicked | { event: 'jarabot_campaign_click' } |
window.dataLayer.push(payload) if a data
layer exists (typical for Google Tag Manager). If only
gtag is loaded, it falls back to
gtag('event', name, payload). If neither is present, the
events are dropped silently — enabling sendGAEvents never
blocks the widget.
Listening from your own code
Because every event lands on window.dataLayer, you can
also react to them without going through GA — handy for triggering
your own analytics or in-page logic:
window.dataLayer = window.dataLayer || [];
const originalPush = window.dataLayer.push.bind(window.dataLayer);
window.dataLayer.push = function (payload) {
if (payload && typeof payload.event === 'string' && payload.event.startsWith('jarabot_')) {
// do something with the event
console.log('Jarabot GA event', payload);
}
return originalPush(payload);
};
jarabot:ready event
Fires once on window when the widget is fully booted and
the window.$jarabot API is ready to use. This is the
right moment to call setUser(),
setCustomAttributes(),
sendMessage() etc.
window.addEventListener('jarabot:ready', function () {
// window.$jarabot is now usable
window.$jarabot.setUser('user-123', {
name: 'Matt Newman',
email: 'matt@example.com'
});
});
jarabot:custom-action event
Fires when the AI Chat Bot (or agent) decides to invoke one of the
custom browser-side actions you advertised through
sendMessage(). The action name comes from
detail_info.available_actions[].action, and any optional
payload the model wants to pass arrives as
event.detail.data.
This is how you let Jarabot drive your own page — refresh a captcha, switch a verification method, retry a payment, etc. — instead of just answering with text.
Payload
event.detail = {
action: string; // matches an `action` from available_actions
data?: object; // optional arguments chosen by the AI Chat Bot
}
Example
window.addEventListener('jarabot:custom-action', function (event) {
const { action, data } = event.detail;
switch (action) {
case 'resend_sms':
skippay.resendSMS();
break;
case 'try_other_method':
skippay.switchMethod();
break;
}
});
detail_info.available_actions when you call
sendMessage(). Each item must have an action (the identifier you'll
receive here) and a label (what the user sees if the
action is surfaced as a button).
jarabot:error event
Fires when the widget fails to load (bad token, network error, blocked
domain). The error detail is in event.detail.
window.addEventListener('jarabot:error', function (event) {
console.error('Jarabot failed to start', event.detail);
});
jarabot:on-message event
Fires every time a message is sent or received in the widget.
event.detail contains the message payload.
window.addEventListener('jarabot:on-message', function (event) {
console.log('Message', event.detail);
});
jarabot:on-start-conversation event
Fires when the visitor starts a new conversation (sends their first message).
window.addEventListener('jarabot:on-start-conversation', function (event) {
// Track this in your analytics
console.log('Conversation started', event.detail);
});
jarabot:opened event
Fires when the chat window opens: the visitor clicks the bubble, you
call window.$jarabot.toggle('open'), or the visitor opens
the full chat from the unread message preview. It fires once for each
open. The unread message preview alone does not fire it. A chat
embedded in the page fires it once, when it has
loaded (for a visitor who gets the robot check, once they are past
it). There is no payload (event.detail is
null).
window.addEventListener('jarabot:opened', function () {
// Hide your own "Need help?" banner while the chat is open
document.querySelector('#help-banner').hidden = true;
});
jarabot:closed event
Fires when the chat window closes: the visitor clicks the bubble or
the close button in the widget, presses Esc, opens the chat in a new
window (pop-out), or you call
window.$jarabot.toggle('close'). It fires once for each
close and only after jarabot:opened. There is no payload.
window.addEventListener('jarabot:closed', function () {
document.querySelector('#help-banner').hidden = false;
});
sendMessage() method
Posts a message into the active conversation on the visitor's behalf,
exactly as if they had typed it into the widget and pressed send. The
server receives a regular visitor message and your bot or agent
replies to it the same way they would to any human input. Pass
detail_info to attach structured context that helps the
agent answer.
Set hidden: true to post the message as
internal. A hidden message is stored on the
conversation and shown to agents in the dashboard (marked with an
“Invisible to customer” eye icon), but it is never displayed
or sent back to the visitor in the widget thread. Use it to pass
silent context to your agents/bot without the visitor seeing it.
On an inbox that starts a new conversation on every page load, a tab
in which the visitor has not started a conversation yet has no active
one. sendMessage() then starts it first, and the visitor
goes on writing in the same conversation. If the conversation cannot
be started, the message is not sent and the callback gets the reason
as a failed result. An inbox with a pre-chat form is the exception:
there the form starts the conversation.
Messages are sent one after another, in the order of the calls.
setUser(), setLabel(),
removeLabel() and the conversation custom attributes
keep their place in that order too: a message sent before
setUser() goes out as the visitor before it, and one
sent right after it waits until the user is applied. When the widget
is open on its home screen, a message that is not hidden brings the
visitor to the conversation.
Pass a function as the second argument to learn how the call ended.
Without it sendMessage() reports nothing.
Signature
window.$jarabot.sendMessage({
message: string; // text sent to the server, as if typed by the visitor
detail_info?: object; // optional structured context
hidden?: boolean; // optional, default false — store as internal, invisible to the visitor
}, callback?: (result) => void)
Result
The callback is called once with the outcome.
result.status is "sent" or
"failed". A call without a text in
message throws an error and does not call the callback.
{ status: "sent", message_id: 123 }
{ status: "failed", error: { code: "rate_limited", http_status: 429 } }
error.code |
Meaning |
|---|---|
rate_limited |
Too many messages came from the visitor's IP address in a short time (HTTP 429). The message was not stored. Wait a few seconds before you send it again, and give up after a few attempts. |
conversation_locked |
The conversation is resolved and the inbox accepts no more messages in it (HTTP 409). The message was not stored. |
request_failed |
The server did not confirm the message for another reason.
http_status holds the HTTP status of its answer.
The message may still have been stored, above all with a status
of 500 or higher.
|
network_error |
The request got no answer from the server, for example because the visitor is offline. It is not known whether the message was stored. |
not_ready |
The widget has not loaded yet, or is loading again after
reset(), so nothing was sent. Call
sendMessage() after
jarabot:ready; after reset() send it again a moment later.
|
timeout |
The widget did not answer within 30 seconds, for example because it reloaded while the message was on its way. It is not known whether the message was stored. |
http_status is null for
network_error, not_ready and
timeout.
Only rate_limited, conversation_locked and
not_ready say for sure that the message was not stored.
After request_failed, network_error or
timeout send it again only when a second copy does no
harm.
Example
window.$jarabot.sendMessage({
message: "Do you need help with entering SMS?",
detail_info: {
text: "The user is stuck at the SMS verification step",
step: "sms_verification",
user_name: "Matt Newman",
attempts: 3,
available_actions: [
{ action: "resend_sms", label: "Re-send SMS" },
{ action: "try_other_method", label: "Try different method" }
]
}
});
Example — hidden (internal) message
window.$jarabot.sendMessage({
message: "Visitor reached the checkout page with 2 items in cart",
hidden: true // visible to agents only, never shown to the visitor
});
Example — send a hidden message again after a failure
function sendCartContext(attempt) {
window.$jarabot.sendMessage(
{
message: "Visitor reached the checkout page with 2 items in cart",
hidden: true
},
function (result) {
if (result.status === "sent") return;
if (result.error.code === "rate_limited" && attempt < 3) {
setTimeout(function () { sendCartContext(attempt + 1); }, 5000);
} else {
console.error("Jarabot did not confirm the message", result.error);
}
}
);
}
window.addEventListener('jarabot:ready', function () {
sendCartContext(1);
});
setUser() method
Associate the current visitor with a known user in your system. Call this right after sign-in. The widget stores a hash of the user data in a cookie and only re-sends to the backend when something changes.
Signature
window.$jarabot.setUser(identifier: string | number, user: {
name?: string;
email?: string;
avatar_url?: string;
identifier_hash?: string; // HMAC-SHA256(identifier) if identity verification is on
phone_number?: string;
description?: string;
country_code?: string;
city?: string;
company_name?: string;
social_profiles?: {
twitter?: string;
linkedin?: string;
facebook?: string;
github?: string;
};
})
Example
window.$jarabot.setUser('user-123', {
name: 'Matt Newman',
email: 'matt@example.com',
avatar_url: 'https://example.com/avatars/matt.png',
phone_number: '+421900000000',
company_name: 'Acme s.r.o.'
});
identifier_hash — an HMAC-SHA256 of the
identifier using your inbox HMAC key, computed on the
server.
setCustomAttributes() method
Attach arbitrary key/value attributes to the contact. Attributes appear on the contact record and can be used in routing, automations, and reports.
window.$jarabot.setCustomAttributes({
plan: 'pro',
signup_date: '2026-01-15',
lifetime_value: 1240
});
deleteCustomAttribute() method
Remove a single custom attribute from the contact.
window.$jarabot.deleteCustomAttribute('plan');
setConversationCustomAttributes() method
Attach attributes to the current conversation (not the contact). Use this for context that only matters for this session — current cart, page funnel step, AB variant, etc.
window.$jarabot.setConversationCustomAttributes({
cart_value: 89.90,
cart_currency: 'EUR',
checkout_step: 'payment'
});
deleteConversationCustomAttribute() method
window.$jarabot.deleteConversationCustomAttribute('checkout_step');
setLabel() method
Apply a label (tag) to the current conversation. Labels must already exist in the account.
window.$jarabot.setLabel('priority-user');
removeLabel() method
window.$jarabot.removeLabel('priority-user');
setLocale() method
Switch the widget UI language at runtime. The locale string matches
what you'd pass to jarabotSettings.locale.
window.$jarabot.setLocale('en');
setColorScheme() method
Switch between light and auto color schemes at runtime — useful when your app has its own dark-mode toggle.
// 'light' or 'auto'
window.$jarabot.setColorScheme('auto');
toggle() method
Open or close the widget programmatically. With no argument it
toggles, or pass 'open' / 'close' to force a
state. A chat embedded in the page is always
open, so there it does nothing.
document.querySelector('#open-chat').addEventListener('click', function () {
window.$jarabot.toggle('open');
});
toggleBubbleVisibility() method
Show or hide the floating bubble launcher. Pass 'hide' or
'show'. A chat embedded in the page
has no bubble, so there it does nothing.
// Hide the bubble on a specific page
window.$jarabot.toggleBubbleVisibility('hide');
popoutChatWindow() method
Pop the conversation out into a standalone browser window. Equivalent to clicking the popout button in the widget header.
window.$jarabot.popoutChatWindow();
reset() method
Clear the current visitor session — wipes the conversation cookie and
the user cookie, then reloads the widget iframe. Call this on logout,
or before setUser() when switching identities.
// On logout
window.$jarabot.reset();
reset() is idempotent — calling it when there is no
active session is safe.