Widget JavaScript API
The SilentChat widget exposes a global object window.SilentChat after loading.
Control the chat window
window.SilentChat.open();
window.SilentChat.close();
window.SilentChat.toggle();
window.SilentChat.hide();
window.SilentChat.show();
Send a message, set visitor information
window.SilentChat.sendMessage('Hello, I am interested in product X');
// Visitor name and email — in every plan.
window.SilentChat.setVisitorInfo({ name: 'Max', email: 'max@example.com' });
// Custom attributes — from Professional.
window.SilentChat.setCustomData({ plan: 'premium', employees: 42 });
// Remove an attribute again: explicitly pass null.
window.SilentChat.setCustomData({ plan: null });
What happens to the attributes. They are stored with the visitor and can be
evaluated in segments as metadata.<key> — for example, you can build a
segment “all visitors in the premium plan".
Limits that we consciously set:
- Maximum of 10 pairs per visitor. Keys up to 40, values up to 200 characters.
- Allowed are text, numbers and yes/no — no nested objects.
- Please do not store personal data in attributes. Values that look like an
email address or phone number are stored masked
(
m***@example.com). For name and email, there issetVisitorInfo— they are intended there and described in the data processing agreement.
If nothing arrives, the console tells you why. Both methods write a warning to the browser console if the plan does not include the attributes or the visitor has not consented to tracking. There is no silent swallowing.
Report custom events
An attribute states what is true about the visitor. An event states what has happened — with a timestamp, and each occurrence individually:
window.SilentChat.track('cart_filled', { value: 249.90, items: 3 });
window.SilentChat.track('demo_booked');
Your agents see the events live in the visitor details column — so what someone has done, not just where they were. Also from Professional.
Names are standardized. Cart filled,
cart-filled and CART_FILLED
all end up as cart_filled. Otherwise, they would be three
different events in every evaluation, without anyone noticing.
Lowercase letters, numbers and underscores remain; umlauts are spelled out.
Limits:
- Maximum of 200 events per session.
- Maximum of 50 different names per account. Anyone who sends a new name
beyond that gets it booked under
_other— the data is not lost, it is just no longer tracked individually. Please do not use identifiers in the names (order_4711), but in the properties. - The same rules apply to the properties as to the attributes — including the masking of anything that looks like an email address or phone number.
- Events are stored as long as page views and removed when the visitor is deleted.
What you can do with events
Segments. In the segment editor, there are two new fields per event:
event.<name>— how often it has occurred. “Is not empty” means “at least once", “is empty” means “never". With greater/less you compare the number.event_days.<name>— days since the last time. “Less than 7" is therefore “in the last week".
Example: event.cart_filled is not empty AND
event.order_completed is empty — everyone who has left something
behind.
Triggers. The condition “Custom Event” responds as soon as
track has been reported in the current session — for example, to
address someone who has filled the cart and then done nothing else. Only the
current session: For “bought something three weeks ago" take a segment.
Consent API (Presence Tracking)
window.SilentChat.setConsent('presence_tracking', true);
window.SilentChat.revokeConsent('presence_tracking');
const state = window.SilentChat.getConsent('presence_tracking');
// "granted" | "declined" | "unknown"
const off = window.SilentChat.onConsentChange((type, granted) => {
console.log('Consent changed:', type, granted);
});
off(); // unsubscribe
Cookiebot Integration
window.addEventListener('CookiebotOnAccept', () => {
if (Cookiebot.consent.statistics) {
window.SilentChat.setConsent('presence_tracking', true);
}
});
window.addEventListener('CookiebotOnDecline', () => {
window.SilentChat.revokeConsent('presence_tracking');
});
Usercentrics V2
window.addEventListener('uc-consent-changed', (event) => {
const v = event.detail?.SilentChat?.consent;
if (v === true) window.SilentChat.setConsent('presence_tracking', true);
if (v === false) window.SilentChat.revokeConsent('presence_tracking');
});
Events
window.SilentChat.on('ready', () => { /* Widget loaded */ });
window.SilentChat.on('chat_opened', () => {});
window.SilentChat.on('chat_closed', () => {});
window.SilentChat.on('message_sent', (msg) => {});
window.SilentChat.on('message_received', (msg) => {});
window.SilentChat.off('chat_opened');
HTML Attributes (Trigger Mode)
<a href="#" data-silentchat-open>Open chat</a>
<div data-silentchat-trigger data-label="Help?" data-style="branded" data-color="#2563eb"></div>
Or via URL hash: https://your-page.de/page#silentchat-open
Embed the widget
<script
src="https://cdn.silentchat.de/silentchat.min.js"
data-widget-key="pk_XXX"
data-api-url="https://api.silentchat.de"
data-ws-url="wss://ws.silentchat.de"
defer
></script>