Examples

Example — Script Loader

A complete HTML page embedding the widget via the iframe loader

The simplest embed: one <script> tag. The widget runs in a sandboxed iframe. This page also shows the window.Wexio() control API and the pre-load queue.

Full page

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Wexio Widget — script loader embed</title>
  </head>
  <body>
    <h1>My website</h1>
    <button id="open">Open chat</button>
    <button id="logout">Log out</button>

    <!-- 1. Pre-load queue: calls made before the loader finishes are buffered. -->
    <script>
      window.Wexio =
        window.Wexio ||
        function () {
          (window.Wexio.q = window.Wexio.q || []).push(arguments);
        };

      // Identify a logged-in user with a server-signed JWT (optional).
      // window.Wexio("identify", { jwt: "<host-signed-jwt>", name: "Ada Lovelace" });

      document.getElementById("open").onclick = () => window.Wexio("show");
      document.getElementById("logout").onclick = () => window.Wexio("shutdown");
    </script>

    <!-- 2. The loader. Swap in your public key. -->
    <script
      async
      src="https://cdn.wexio.io/widget/loader.js"
      data-public-key="pk_live_..."
    ></script>
  </body>
</html>

What to change

TokenReplace with
pk_live_...Your public key.
<host-signed-jwt>A server-signed JWT — only if you identify visitors.

On this page