Skip to content
中文

Test your embed

Before going live, verify conversations and refusal paths in your actual host website. These are acceptance scenarios to execute. A visible component or praxis.ready proves mounting, not successful authentication or a model reply.

Prepare the test environment

Use an isolated service agent, available model and environment, saved embed settings, and an integrated host page. Allow that page’s actual origin and set an affordable budget. Prepare host test accounts A and B with distinct customer_id values derived from authenticated server sessions.

First select a version and send a question in Service agents → Select agent → Integrate → Playground (接入 → 试用调试). This checks configuration. Then test the host below. Dashboard simulation does not test host login, domains or token endpoints, and does not enter customer operations statistics.

Run acceptance scenarios

Input or actionExpected result and verification
A logs in and asks about a courseAn actual reply appears; the Sessions (会话) tab contains the same message, user and source
Call your host grant-code endpoint while logged outThe host refuses issuance and returns no grant code
Load from an origin outside the allowlistAccess fails; an API response can report EMBED_ORIGIN_NOT_ALLOWED (403). Browser framing policy can block an iframe first
Issue a grant code with expires_in: 59INVALID_PARAMS (400), with no usable grant code
Submit agent_override while host overrides are disabledEMBED_FIELD_NOT_ALLOWED (400); browser input cannot change trusted instructions
Issue for a blocked userEMBED_USER_BLOCKED (403)
Create a session at the active-session limitEMBED_RATE_LIMITED (429); wait for runs to finish rather than deleting idle history
Create at the monthly cap with “Stop new sessions”EMBED_MONTHLY_CAP_REACHED (402); do not manufacture this condition on an agent serving real users
Invoke a declared client toolThe intended page effect and result occur; unknown tools, invalid arguments or missing business permissions fail. A confirmation card alone is insufficient

Use this standalone script to check the expiry minimum. On your server, set PRAXIS_API_BASE (API origin), PRAXIS_API_KEY (organization API Key), and PRAXIS_AGENT (real agent_… ID). Save it as test-token-limit.mjs and run node test-token-limit.mjs with Node.js supporting native fetch. Configure the policy first; otherwise missing configuration fails before expiry validation.

import assert from 'node:assert/strict';
const { PRAXIS_API_BASE, PRAXIS_API_KEY, PRAXIS_AGENT } = process.env;
assert(PRAXIS_API_BASE && PRAXIS_API_KEY && PRAXIS_AGENT, 'Set the three environment variables');
assert(PRAXIS_AGENT.startsWith('agent_'), 'Use the public agent ID');
const response = await fetch(`${PRAXIS_API_BASE.replace(/\/$/, '')}/customer/v1/grant_codes`, {
method: 'POST',
headers: { Authorization: `Bearer ${PRAXIS_API_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ customer_id: 'docs_test_a', resources: [`agent:${PRAXIS_AGENT}:chat`], expires_in: 59 }),
});
assert.equal(response.status, 400, 'Invalid expiry must be rejected');
console.log({ status: response.status, requestId: response.headers.get('X-Request-Id') });

Expected: Exit successfully with status: 400. This checks refusal status only; separately inspect the error body for INVALID_PARAMS and the expiry field message. The script prints no credentials and does not replace successful issuance and reply tests.

Verify identity and lifecycle

  1. After A starts a session, log out and destroy A’s component. Log in as B with a new component. A’s sessions must be absent from history, and reading A’s session with B’s token must fail. Clearing the interface alone does not switch identity.
  2. Keep A logged in through a token renewal (at 80% of its lifetime). Subsequent messages must still belong to A, and a streaming reply must not stop. When the token is refused (SIGN_IN_REVOKED / SIGN_IN_EXPIRED, 401), confirm the page takes a new code after praxis.session.end and your endpoint rechecks the login.
  3. On A’s sign-out, have the page call session.signOut(). Confirm DELETE /customer/v1/access_tokens/current returns 204, the old token is refused afterwards, and the component does not sign in again by itself; the element’s element.signOut() only clears the conversation and detaches from the page session. Test user-wide revocation, blocking and unblocking with Manage customers.
  4. Anonymous (publishable-key) tokens live in page memory only, so a reload is a new visitor. When a visitor then logs in to your site, confirm your backend passes the anonymous customer id as merge_customer_id to POST /customer/v1/grant_codes and the identified customer sees the anonymous sessions.
  5. For Hosted, test exchange after 60 seconds, repeated exchange, and token expiry in an open page. The first two fail. The open page does not refresh its token automatically; obtain a new link from the host.

Diagnose and clean up

Record time, environment, component version, expected and actual results, plus failed responses’ X-Request-Id, status and error code. An error event may contain only message; inspect browser network responses for details. Exclude Keys, tokens and visitor credentials.

Revoke test tokens, archive unused test sessions, and restore temporary limits and blocked states. Archiving retains records. Run one successful conversation with normal configuration afterward to confirm cleanup left no access problems.

Next: Go-live checklist · Limits and errors · Agent API