Skip to content
中文

Component reference

<praxis-agent> renders an agent conversation on your website. Initialize it with element.setOptions(options). This reference covers properties, methods and events. For integration steps, see Embed in a web page.

Initialize

Initial options require agent.name. Prefer calling configure() from praxis-session.js once, so the element takes its API address and token from the page session (see Customer sign-in); api.url is then unnecessary and agent.id may be omitted. An element may also carry its own credential: give api.url plus exactly one of api.grantCode or api.publishableKey; missing values, or both credentials, throw TypeError. An element’s own credential uses the deprecated per-agent route, which will be removed. The npm package is @deepraxis/kit (React binding: @deepraxis/kit-react).

This is an anonymous page-session example. Create a publishable key, save embed settings, and allow your host origin. Replace PRAXIS_PUBLISHABLE_KEY and agent_REPLACE_ME, and serve this HTML from that origin. A publishable key is not a server API Key.

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Course assistant</title>
<script type="module">
import { configure } from "https://cdn.deepraxis.com/v1/praxis-session.js";
// An anonymous visitor uses a publishable key; do not also configure a grantCode on the same page.
configure({ api: { url: 'https://api.deepraxis.com', publishableKey: 'PRAXIS_PUBLISHABLE_KEY' } });
</script>
<script type="module" src="https://cdn.deepraxis.com/v1/praxis-kit.js"></script>
<praxis-agent style="display:block;height:600px;width:100%"></praxis-agent>
<p id="status" role="status"></p>
<script type="module">
await customElements.whenDefined('praxis-agent');
const agent = document.querySelector('praxis-agent');
const status = document.querySelector('#status');
agent.addEventListener('praxis.ready', () => { status.textContent = 'Interface mounted'; });
agent.addEventListener('praxis.error', () => { status.textContent = 'Check the failed network request'; });
agent.setOptions({
agent: { id: 'agent_REPLACE_ME', name: 'Course assistant' },
locale: 'en',
});
</script>
</html>

Expected: A chat interface appears and sending a question produces a real reply. Interface mounted only confirms mounting; also verify replies and user isolation.

Properties

api and agent

PropertyTypeMeaning
api.urlstringAPI origin or base ending in /agent/v1; immutable after initialization; optional in page-session mode
api.grantCode({ anonymousAccessToken?: string }) => Promise<string>Deprecated, will be removed. For an element that carries its own credential: returns a one-time grant code from your backend
api.publishableKeystringDeprecated, will be removed. For an element that carries its own credential: publishable key for anonymous visitors
agent.idstringThe public ID agent_… or the identity number; required with the element’s own credential, optional in page-session mode
agent.namestringRequired display name; does not select an agent
agent.avatarstringAvatar URL; credentials determine the actual agent accessed
onClientTool(call: { id, name, input }) => unknown | Promise<unknown>Element property, outside setOptions. Handles client tools; throw for unknown tools

Layout and content

PropertyType / defaultEffect
layoutinline, sidebar, popup, modal; default inlineConversation layout
widthnumber; 400 CSS pixelsSidebar width
launcher.typenone, bubble, mascotRequired when supplying launcher; defaults to none for inline, bubble otherwise
launcher.image, launcher.labelstringLauncher image and text
launcher.positionbottom-right, bottom-leftLauncher position; defaults to bottom-right
header.title, header.subtitlestringTitle and subtitle; title defaults to agent.name
header.iconstringSupported Lucide icon name or image URL
header.actions{ id: string; icon: string; label: string }[]Custom header buttons emitting click events
history.enabledboolean; trueHistory entry; false also disables showHistory()
startScreen.greetingstringEmpty-conversation greeting
startScreen.prompts{ label: string; prompt: string }[]Displays the first 4; clicking sends prompt
composer.placeholderstringDefaults to the localized input hint
composer.attachments.enabledboolean; trueAllows file selection, pasting and dropping
disclaimer, footerstringConversation notice and footer text
autoScrollbooleanWhether new content scrolls automatically
localezh, enFalls back to host page language, then browser language. Tags starting with zh select Chinese; otherwise English. No language information defaults to English

theme

PropertyValues / constraints
colorSchemelight, dark, system; light when omitted, system follows the browser
accent, surfaceExplicit opaque CSS colors; var(), currentcolor and transparency throw TypeError
grayscaleneutral, warm, cool
radiusnone, sm, md, lg, full; base radii of 0, 4, 10, 18, 9999 CSS pixels
densitycompact, normal, spacious; base spacing of 3, 4, 5 CSS pixels
fontFamilyNonempty font-family string without ; { } < >; otherwise TypeError
fontSizePositive finite number in CSS pixels; otherwise RangeError

Default accent colors are #167A43 in light mode and #30a46c in dark mode. Foreground colors are selected for contrast.

React props

PraxisAgent from @deepraxis/kit-react uses these props. Prefer calling configure() once at the page entry (see Customer sign-in); the component takes its identity from the page session. The top-level grantCode and options.api.publishableKey are the deprecated element-own-credential props, which will be removed.

Prop / return objectMeaning
grantCodeDeprecated, will be removed. Same signature as api.grantCode; replacing the function does not sign in again
optionsOptions above; api holds only url and publishableKey. Omission renders an unconfigured element
layout, launcherOverride options.layout and options.launcher.type; launcher accepts none/bubble/mascot
className, style, childrenHost element styling and React children
onClientToolClient tool callback, matching the element property
ref / usePraxisAgent()ref exposes a control handle; the hook returns stable { ref, control }

Methods

MethodReturn / behavior
setOptions(partial)Initializes or merges options
sendUserMessage(text)Promise<"accepted" | "rejected" | "unknown">; can reject empty or oversized text, pending approvals or unavailable submission. accepted does not prove a successful reply; inspect the session before resending an unknown result
setComposerValue(text)Replaces the draft without sending
focusComposer()Focuses the composer; no effect while history is open
setThreadId(id)Switches sessions and closes history; null opens an empty conversation, not a different user identity
showHistory(), hideHistory()Opens or closes history
open(), close(), toggle()Opens, closes or toggles the panel; no effect for inline
setReadable(name, value)Registers page context. Name: 1–64 characters, letters, digits or _ . : -. Value: string or JSON-serializable value
removeReadable(name)Removes the named page value
signOut()Promise<void>; clears the conversation on screen and detaches from the page session. The page ends the session itself with session.signOut() (DELETE /customer/v1/access_tokens/current), then takes a new code and calls configure()

The React control handle includes the methods from sendUserMessage through toggle above, plus signOut. Calls before onReady or after unmount throw a not-ready error rather than queueing. For React page context and tools, use usePraxisReadable and usePraxisTool, with PraxisProvider when sharing a registry scope. See the guides below.

Events

Events are bubbling, composed CustomEvent objects that cross Shadow DOM. React callbacks receive the same event object; read its event.detail.

Event / React callbackDetail and timing
praxis.ready / onReadyNone; interface mounted, not proof of authentication or network success
praxis.error / onErrorKitError with code, status, retryable, message, or only { message }; check fields before using them
praxis.thread.change / onThreadChange{ threadId: string | null }; current session changed
praxis.response.start / onResponseStartNone; processing became busy
praxis.response.end / onResponseEndNone; processing stopped being busy, not a success assertion
praxis.open, praxis.close / onOpen, onCloseNone; panel opened or closed
praxis.history.open, praxis.history.close / onHistoryOpen, onHistoryCloseNone; history opened or closed
praxis.header.action / onHeaderAction{ id: string }; custom header button clicked
praxis.tool.change / onToolChange{ id, name, status: "start" | "end", isError? }; client tool execution changed
praxis.log / onLog{ level: "info" | "warn" | "error", message, data? }; context trimming or tool diagnostics
praxis.frame.closeNone; requests that the host close an iframe; no corresponding React callback prop

Defaults and lifecycle

setOptions merges objects recursively and replaces arrays. Explicit undefined resets a field. Changing api.url after initialization throws TypeError. In page-session mode, calling configure() again with another identity signs in again without affecting requests in flight. Call signOut() before switching users. Removing an element releases connections and renewal timers but does not end the sign-in on the server.

Page context snapshots allow 32 items and 4096 UTF-8 bytes. Excess entries are omitted starting with the earliest registration, with a log event. These runtime options are separate from Dashboard-persisted iframe/Hosted appearance, which has its own fields and size limits.

Usage guides

Customer sign-in · Pass context · Add client tools · Customize appearance