Jarabot Jarabot SDK
jarabot.com

Jarabot Widget SDK

Embed the Jarabot chat widget on any website and drive it from JavaScript — pass user context, push suggestions, attach custom attributes, and react to conversation events.

Getting Started

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",
    "showPopoutButton": false,
    "showUnreadMessagesDialog": true,
    "widgetStyle": "standard",
    "darkMode": "light",
    "widgetOffsetX": null,
    "widgetOffsetY": null,
    "userMessageColor": null,
    "productButtonColor": null,
    "productButtonLabel": null,
    "backButton": true,
    "sendGAEvents": false
  };

  (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>
Where to find your website token Inboxes → select your website inbox → Configuration. The token is shown in the embed snippet.

Add a question suggestion

Question suggestions are clickable prompts shown to the visitor inside the widget. Use them to surface contextual help based on what the visitor is doing on your page — 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.addQuestionSuggestion({
    message: "Do you need help with entering SMS?",
    prompt: "User stacked on SMS code verification",
    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 what the visitor sees on the suggestion chip. prompt and detail_info are passed to the agent / bot when the visitor accepts the suggestion, so use them to carry whatever context will let the agent help the user immediately.

Configuration

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".
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".
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.
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.
sendGAEvents boolean false Push widget interaction events to window.dataLayer / gtag. 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.
Calling order Calling 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

When jarabotSettings.sendGAEvents is set to true, 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 { 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' }
jarabot_custom_campaign_shown Phase 1 popup appeared { event: 'jarabot_external_event_shown', step: '...' }
jarabot_custom_campaign_clicked Phase 1 popup clicked { event: 'jarabot_external_event_clicked', step: '...' }
How events are dispatched The widget calls 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);
};
Lifecycle Events

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(), addQuestionSuggestion() 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 addQuestionSuggestion(). 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;
  }
});
How actions get registered The list of actions the AI Chat Bot can call is whatever you pass in detail_info.available_actions when you call addQuestionSuggestion(). 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);
});
SDK Methods

addQuestionSuggestion() method

Pushes a contextual question suggestion into the active conversation. The visitor sees it as a clickable chip; tapping it sends the question along with the prompt and detail payload to your bot or agent.

Signature

window.$jarabot.addQuestionSuggestion({
  message: string;       // visible chip text
  prompt: string;        // hidden prompt sent to the bot
  detail_info?: object;  // optional structured context
})

Example

window.$jarabot.addQuestionSuggestion({
  message: "Do you need help with entering SMS?",
  prompt: "User stacked on SMS code verification",
  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" }
    ]
  }
});

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.'
});
Identity verification If you enable HMAC identity verification on the inbox, you must also pass 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.

document.querySelector('#open-chat').addEventListener('click', function () {
  window.$jarabot.toggle('open');
});

toggleBubbleVisibility() method

Show or hide the floating bubble launcher. Pass 'hide' or 'show'.

// 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();
Tip reset() is idempotent — calling it when there is no active session is safe.