Your backend
The backend is the same one the website chat uses. Follow Logged-in users for the session flow and the Node and Python sketches. Your token endpoint returns:The app
PassChatAuth.server with a getToken callback that calls your token endpoint with your app’s own authentication:
ServerToken.fromJson accepts sessionId, token, wsUrl and expiresAt, or the snake_case names session_id, ws_url and expires_at, so your endpoint can pass the Osvi AI response through. expiresAt may be in seconds or milliseconds.
The SDK calls getToken when the chat starts, about every 4.5 minutes while it is connected, after the server rejects a token, and with newSession: true when the visitor taps New chat. If getToken throws, state.error has the code token_failed and the chat shows Try again.
wsUrl must use wss://. The client accepts ws:// only for localhost and 127.0.0.1, for local development; anything else fails with token_failed.
Identity
A server-mode client belongs to one customer. When the customer logs out or switches accounts, calldispose() on the client and create a new one for the next customer. In server mode the client stores no visitor ID and no session ID on the device.
Your token endpoint is your security boundary: authenticate the user, take the customer ID from your own session rather than from the request, and rate-limit the endpoint. Do not use the visitor format (web: followed by 16 to 64 URL-safe characters) as a customer ID; Osvi AI rejects it with 422 invalid_customer_id.