Kako Vam možemo pomoći?

Ukratko nam recite o čemu je riječ – odgovorit ćemo Vam e-poštom.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Na početnu stranicu

JavaScript API: controlling the widget from your page

All commands of window.ReactiveChat – open, close, send messages, identify users, control the teaser and promo card, start tours, query the session – with parameters, return values and the queue before loading.

The widget provides a single global object: window.ReactiveChat. You call all commands in the function form:

ReactiveChat('command', argument1, argument2);

The names of the basic commands follow common chat widgets (boot, shutdown, open, identify, update, track …), so that switching over takes little work.

The queue before loading

The loader creates ReactiveChat first. Until the core has loaded, this version records every call in ReactiveChat.q; the core then works through the list in order. No call is lost.

If your code might run before the loader tag, put this line in front of it:

window.ReactiveChat = window.ReactiveChat || function () {
  (window.ReactiveChat.q = window.ReactiveChat.q || []).push(arguments);
};

Two things follow from this:

Commands never throw: an error in a command results in undefined, an unknown command is ignored (with data-rc-debug="true" it appears in the console).

ReactiveChat('on', 'ready', function () {
  var s = ReactiveChat('getSession');
  console.log('Visitor', s && s.visitorId);
});

Start-up and shutdown

ReactiveChat('boot', { locale: 'en', theme: 'dark' });

Window

document.querySelector('#hilfe').addEventListener('click', function (ev) {
  ReactiveChat('open', { anchor: ev.currentTarget, message: 'Question about my order', tab: 'msg' });
});

Messages and conversations

Visitors and context

ReactiveChat('track', 'produkt_angesehen', {
  page_type: 'product', product_id: 'SKU-4711', price: 49.9, currency: 'EUR', in_stock: true
});

Language, theme

Teaser, promo card, tours

A/B tests

ReactiveChat('on', 'ready', function () { ReactiveChat('abGoal'); });

Design at runtime

The fields of these objects are described under Customisation.

Events

Directly on the object

Once loaded, some commands are also available as methods: ReactiveChat.getSession(), ReactiveChat.isOpen(), ReactiveChat.getEndpoint(), ReactiveChat.startConversation(), ReactiveChat.continueConversation(). In addition, ReactiveChat.version (version of the core). These methods do not exist before loading – the function form is the safe way.

What does not exist

So that nobody goes looking: there are no commands destroy, reset, setUser, send, setConsent, trackPage or navigate. You control consent through your consent platform or data-rc-consent (Privacy integration), the widget detects page changes by itself (SPA), and for signing out see Identifying visitors.

Next: Events

Zadnje ažuriranje: