Skip to main content

REFERENCE

SDK Demos

How to use @asgard-js/core and @asgard-js/react, with demos you can try on the page.

Chatbot Props

Every prop supported by the <Chatbot> component from @asgard-js/react.

  1. Required​

    PropTypeDescription
    configClientConfigClient config; must include botProviderEndpoint
    customChannelIdstringUnique channel id on your side (user id / session id)
  2. Display​

    PropTypeDefaultDescription
    titlestring—Header title (the bot-name row, distinct from channelTitle)
    avatarstring—Bot avatar URL
    botTypingPlaceholderstring—Deprecated (since 0.3.x) — no longer renders anything. The run-in-progress cue is now a connection-bound running indicator shown automatically (no prop needed)
    locale'en-US' | 'ja-JP' | 'zh-TW''en-US'Language for built-in text: tool-call labels, group summary, Task / Subagent panels. See Locales
    channelTitlestring | null—Seed for the thread-top title row (usually from channelMetadata()); updates live from the backend title.update event. See Channel Title
    inputPlaceholderstring—Input box placeholder
    fullScreenbooleanfalseRender in full-screen mode
    classNamestring—Outer className
    styleCSSProperties—Outer inline style
    loadingComponentReactNode—Custom loading UI
  3. Feature Toggles​

    PropTypeDescription
    enableUploadbooleanEnable the image upload button
    enableDocumentUploadbooleanEnable the document upload button
    allowedImageMimeTypesstring[]Restrict image MIME types for enableUpload; when set it fully overrides the default list. See File Upload
    allowedDocumentMimeTypesstring[]Restrict document MIME types for enableDocumentUpload; when set it fully overrides the default list. See File Upload
    enableExportbooleanEnable conversation export
    enableLoadConfigFromServicebooleanLoad remote config (e.g. embedConfig) from bot provider
    maintainConnectionWhenClosedbooleanKeep the SSE connection alive when the window is closed
    keepConnectionOnUnmountbooleanDefault false. Keep an in-flight SSE run alive when the component unmounts so it can finish on the backend (distinct from maintainConnectionWhenClosed, which is the window-closed case)
    autoResetChannelbooleanDefault true. Since 0.3.x, mount first checks channel metadata: a channel that already exists on the backend is always restored (history replayed) regardless of this flag; only for a not-yet-existing channel does false skip RESET_CHANNEL to preserve initMessages. See Auto Reset Channel
    userIdentityHintstringUser identity hint; when set, all requests (SSE, upload) send the X-ASGARD-USER-IDENTITY-HINT header

    See the Feature Toggles demo.

  4. Init Messages & Events​

    PropTypeDescription
    initMessagesConversationMessage[]Initial messages loaded on mount
    onSseMessage(response, { conversation }) => voidCallback fired on every SSE event
    onSseError(error: unknown) => voidSSE error callback
    onBeforeSendMessage(params) => paramsModify params before sending. See before-send-message
    onMessageSent() => voidFired after a message has been sent
    onChannelReady() => voidFired once the channel is ready to accept messages (the ref is updated, so you can send an opening message from the ref inside the callback); re-fires after resetChannel
    onReset() => voidFired when the channel is reset
    onClose() => voidFired when the chatbot is closed
  5. Custom Rendering​

    PropTypeDescription
    themePartial<AsgardThemeContextValue>Theme overrides — see Theme demo
    renderHeader() => ReactNodeReplace the default header — see Custom Header
    renderFooter() => ReactNodeReplace the default footer (input area) entirely — see Custom Footer
    renderMenu() => ReactNodeInsert a menu between body and footer — see Render Menu
    renderTitle(props) => ReactNodeReplace the thread-top title row (props is { title, renderDefault }; return null to hide). Pairs with untitledLabel (fallback for unnamed, default 新對話) and channelTitleHidden. See Channel Title
    renderMessageContent(props) => ReactNodeReplace message content rendering — see Custom Renderer
    renderToolCallGroup(props) => ReactNodeCustomize or hide the tool-call group — see Tool Call
    errorMessageRenderer(message) => ReactNodeCustom error message renderer
    customActionsReactNode[]Custom buttons rendered on the right of the header
    footerEndActionsReactNode[]Custom nodes rendered at the trailing end of the footer input row (after send/mic) — see Footer End Actions
    messageActions(message) => MessageActionConfig[]Action buttons under each bot message
    onMessageAction(actionId, message) => voidCallback when a message action is clicked
    onTemplateBtnClick(payload, eventName, raw) => voidCallback for button-template emit actions
    onErrorClick(message) => voidCallback when an error message is clicked
    defaultLinkTarget'_blank' | '_self' | '_parent' | '_top'Default target for links in messages
    hideRunChromebooleanDo not render the built-in docked Task / Subagent panels — place them yourself, see Docking Panels
  6. Sandbox​

    PropTypeDescription
    fileExplorer'builtin' | 'off'The built-in File Explorer aside; defaults to 'builtin'. Set 'off' to place <FileExplorerPanel> yourself. See File Explorer
    autoRevealOnOpenFileCardbooleanWhether an arriving open-file card auto-reveals the aside (default true); suppressed while a file has unsaved edits
    fileExplorerBasePathstringOverride the tree root (absolute path) instead of the sandbox's workingDirectory
    onSandboxOpenBrowser(sandboxName) => voidTake over a sandbox://<name>/open-browser card; when set the SDK defers to you. See Handoff Cards
    onSandboxOpenFile(sandboxName, absolutePath) => voidTake over a sandbox://<name>/open-file card. Additive, not a replacement — the built-in aside is still revealed unless you also set fileExplorer="off"
    sandboxBrowserOpenTarget'_blank' | '_self' | '_parent' | '_top'Where the default open-browser handler opens the tab; defaults to '_blank'
  7. Auth​

    PropTypeDescription
    authStateAuthStateCurrent auth state — see values below and Auth demo
    onApiKeySubmit(apiKey: string) => Promise<void>Fired when the user submits an API key
    onAuthError(error: { isAuthError, isBotProviderError, errorDetail }) => voidAuth error callback

    AuthState possible values: 'loading' | 'needApiKey' | 'authenticated' | 'error' | 'invalidApiKey' | 'subscriptionExpired' | 'botNotFound'

  8. ClientConfig Fields​

    The config prop is of type ClientConfig:

    FieldTypeDescription
    botProviderEndpointstringRequired. Bot provider base URL
    endpointstring@deprecated — use botProviderEndpoint
    apiKeystringStatic API key
    customHeadersRecord<string, string>Custom HTTP headers (e.g. Authorization: Bearer ...)
    transformSsePayload(payload) => payloadMutate the SSE payload before sending
    debugModebooleanEnable debug logs
    onRunInit / onMessage / onToolCall / onProcess / onRunDone / onRunErrorEventHandlerPer-SSE-event handlers

    Setting botProviderEndpoint to the literal string "skip" enables preview mode: no connection is established, only initMessages are rendered. Many demos on this site use preview mode.

  9. See Also​

  10. Further Reading​

    For the complete SDK API reference, see the Asgard developer docs:

Ready to get started?

Want to see how Asgard fits your team? Talk to us.

Contact us