Client chat quickstart

Start with Getting started, then implement the backend ticket endpoint and mount the current harness module.

1. Prepare access

Use the authenticated backend contract. Publish the exact HTTPS host origin and active web configuration. Keep your tenant server key and mint token on the backend.

2. Mount the supplied loader

Text
<div id="client-chat" style="height:640px"></div>
JavaScript
const HARNESS_ORIGIN = 'https://chat.example.com';
// Copy this independent key ring and workspace ID from your console snippet.
const PUBLIC_KEYS = { 'SUPPLIED_KEY_ID': 'SUPPLIED_PUBLIC_KEY_HEX' };
const { mountWidget } = await import(`${HARNESS_ORIGIN}/embed/loader.mjs`);
const chat = await mountWidget({
  organizationId: 'YOUR_ORG_ID',
  baseUrl: HARNESS_ORIGIN,
  publicKeys: PUBLIC_KEYS,
  container: document.getElementById('client-chat'),
  getSession: async () => {
    const response = await fetch('/chat/session', {
      method: 'POST', credentials: 'same-origin', cache: 'no-store',
    });
    if (!response.ok) throw new Error('Chat could not open.');
    return response.json(); // { ticket, nonce, signedConfig }
  },
});
// On logout or account change:
// chat.destroy();

3. Check a complete session

Check one full answer, Stop, settled receipt, expiry renewal, low balance and logout. Follow the full mount contract for bootstrap requirements and platform checks before enabling production.