Installing the widget
The snippet, what is configured in the dashboard, how the window behaves and what the widget does not do yet.
The snippet #
The script is added once before </body>. Everything else — colour, texts, sound, icon, channels — comes from the server by data-widget-id and is changed in the dashboard without touching the page.
<script async
src="https://api.widgetchat.ru/widget/bozex-support-widget.js"
data-widget-id="wc_9qA…Lk"
></script>One widget per page. The script is async: it does not block rendering and does not wait for the page to load.
What the widget requests #
The look and the texts. The answer is allowed only for the domains declared in the site card: another page carrying your widget id gets no settings.
{"widgetId": "wc_9qA…Lk", "workspaceKey": "example-ru",
"apiUrl": "https://api.widgetchat.ru",
"tokenUrl": "https://api.widgetchat.ru/widget/token/wc_9qA…Lk",
"appearance": {"color": "#07aa46", "title": "Message us", … }}The visitor's entrance #
The widget fetches a signed window token itself and works with it. The token is bound to the site's workspace and lives for a limited time; the visitor is recognised by their device, so the history survives between visits.
There is no programmatic visitor identification yet (passing your own name, email or customer id from the page code). Visitor details appear in a conversation only if the site itself passed them when issuing the token on its side.
Domains #
The list of domains is set in the site card. A widget on an undeclared domain is refused the settings request — that protects you from another page installing your widget id.