Agent

Component reference

Look up PraxisKit properties, methods, events and default behavior by object.

<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 api.url, agent.name, and either api.getToken or api.publishableKey. Missing values throw TypeError. Choose getToken for authenticated users or publishableKey for anonymous visitors. Supply one; when both are supplied, the publishable key takes precedence and getToken is not called.

This anonymous example targets Develop. Create a publishable key there, save an embed policy, and allow your host origin. Replace PRAXIS_PUBLISHABLE_KEY and serve this HTML from that origin. A publishable key is not a server API Key. The script URL, version and integrity value must belong to the same release.

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Course assistant</title>
<script type="module"
  src="https://kit-develop.praxisusercontent.com/v0.2.8/praxis-kit.js"
  integrity="sha384-vey+VZZcFIWJq9Fmv/nmLxspKtXRiL8XiDOfg2g2QFvwZi5MA+tkiQvPBtoMS8eU"
  crossorigin="anonymous"></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({
    api: {
      url: 'https://api-develop.deepraxis.com',
      publishableKey: 'PRAXIS_PUBLISHABLE_KEY',
    },
    agent: { 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.urlstringRequired API origin or base ending in /agent/v1; immutable after initialization
api.getToken(current: string | null) => Promise<string>Returns an embed token. Initially current is null; refresh receives the current token. Recheck host login on your backend every time
api.publishableKeystringAnonymous token entry point instead of getToken; immutable after initialization. A privately stored visitor_secret preserves visitor identity
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

React's PraxisAgent uses these props. The current React binding still requires a top-level getToken, even though options.api includes publishableKey in its type. For anonymous access, use the Web Component above directly.

Prop / return objectMeaning
getTokenRequired; same signature as api.getToken
optionsOptions above without api.getToken; 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

The React control handle includes the methods from sendUserMessage through toggle above. 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 or api.publishableKey after initialization throws TypeError. Destroy and recreate the element when changing backends or user identity. Removing an element releases connections and refresh timers, but does not revoke issued tokens.

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

Embed tokens and users · Pass context · Add client tools · Customize appearance

Export

On this page