Configuration Complete reference for all ChatWidget props
Complete reference for all ChatWidget and PopupChatWidget configuration options.
For setup and authentication, see Quick Start .
Prop Type Default Description agentIdstring- Ensemble agent ID to connect to agentVersionAgentVersion'latest'Agent version selector
'latest' - Use the latest version (including drafts)
'published' - Use the latest published version
number - Use a specific version number (e.g., 1, 2)
< ChatWidget
agentId = "agent-abc123"
agentVersion = "published"
// ...
/>
Prop Type Default Description titlestring- Title displayed in the header inputPlaceholderstring'Type a message...'Placeholder text for input field displayMode'brief' | 'full''brief'Message display mode classNamestring- Additional CSS class for the container stylesChatWidgetStyles- Style customization (see Styling Reference )
'brief' - Collapses previous agent steps, showing only the final response
'full' - Shows all steps and intermediate responses
< ChatWidget
title = "Support Assistant"
inputPlaceholder = "Ask me anything..."
displayMode = "full"
// ...
/>
Prop Type Description initialAssistantMessagestringStatic greeting displayed from the assistant initialUserMessagestringMessage sent to the agent immediately on load
These props only apply when there is no existing message history for the thread. If the user has chatted before, these are ignored.
initialAssistantMessage - Displays a static intro message from the assistant (does not invoke the agent)
initialUserMessage - Sends a message to the agent immediately, triggering a response
If both are provided, initialUserMessage takes precedence and initialAssistantMessage is skipped.
// Show a static greeting (no agent call)
< ChatWidget
initialAssistantMessage = "Hi! How can I help you today?"
// ...
/>
// Auto-start conversation (sends to agent immediately)
< ChatWidget
initialUserMessage = "Show me my account summary"
// ...
/>
Prop Type Description dataContextRecord<string, unknown>Key/value pairs passed to the agent and tools
Context can be passed in two ways:
Secure context - Via JWT token (tamper-proof, server-side)
Client context - Via dataContext prop (for non-sensitive data)
Both are merged, with JWT context taking priority on conflicts.
< ChatWidget
dataContext = {{
environment: 'production' ,
userPreferences: { theme: 'dark' },
}}
// ...
/>
Prop Type Description voiceChatWidgetVoiceOptionsText-to-speech configuration
Property Type Default Description urlstring- TTS API endpoint URL enabledbooleanfalseEnable voice playback methodstring'POST'HTTP method headersRecord<string, string>- Request headers payloadRecord | (text: string) => Record- Request body or function to generate it autoplayLatestbooleanfalseAuto-play the latest response
< ChatWidget
voice = {{
url: 'https://api.example.com/tts' ,
enabled: true ,
headers: { Authorization: 'Bearer ...' },
payload : ( text ) => ({ text, voice: 'en-US-Neural' }),
autoplayLatest: true ,
}}
// ...
/>
Prop Type Description speechToTextChatWidgetSpeechToTextOptionsSpeech recognition configuration
Property Type Default Description enabledbooleanfalseEnable microphone input languagestring'en-US'Recognition language (BCP-47 code) silenceTimeoutnumber2000Silence duration (ms) before auto-stop finalDelaynumber- Delay before finalizing transcript onError(message: string) => void- Error callback
< ChatWidget
speechToText = {{
enabled: true ,
language: 'en-US' ,
silenceTimeout: 3000 ,
onError : ( msg ) => console. error ( 'Speech error:' , msg),
}}
// ...
/>
Prop Type Description feedbackChatWidgetFeedbackOptionsMessage feedback configuration
Property Type Default Description enabledbooleantrueShow thumbs up/down on assistant messages requireCommentForNegativebooleanfalseRequire comment when giving negative feedback
Feedback is submitted to POST {baseUrl}/api/feedback.
< ChatWidget
feedback = {{
enabled: true ,
requireCommentForNegative: true ,
}}
// ...
/>
Prop Type Description widgetsUIWidgetDefinition[]Custom widget renderers
See Custom Widgets for details.
Prop Type Description onError(error: Error) => voidCalled on API errors onAuthError() => Promise<string | null>Called on 401; return new token to retry onFinish(message: any) => voidCalled when assistant finishes responding onData(data: any) => voidCalled on streaming data chunks onMessage(message: UIMessage) => voidCalled when a message is added
< ChatWidget
onError = {( err ) => console. error ( 'Chat error:' , err)}
onAuthError = { async () => {
const newToken = await refreshToken ();
return newToken;
}}
onFinish = {( msg ) => console. log ( 'Response complete:' , msg)}
// ...
/>
Access the widget programmatically using a ref:
import { useRef } from 'react' ;
import { ChatWidget, ChatWidgetHandle } from '@anthropic/client-sdk' ;
function App () {
const chatRef = useRef < ChatWidgetHandle >( null );
const sendGreeting = () => {
chatRef.current?. sendMessage ( 'Hello!' );
};
return (
<>
< button onClick = {sendGreeting}>Send Greeting</ button >
< ChatWidget ref = {chatRef} /* ... */ />
</>
);
}
Method Type Description sendMessage(message: string) => voidSend a message programmatically
PopupChatWidget accepts all ChatWidget props plus:
Prop Type Default Description anchorPosition'end' | 'start''end'Position of floating button (end = right, start = left) defaultOpenbooleanfalseWhether popup is open by default
< PopupChatWidget
anchorPosition = "end"
defaultOpen = { false }
title = "Help"
// ... all ChatWidget props
/>