ChatInterface Component
TheChatInterface
component offers extensive configuration options to customize behavior, appearance, and functionality.
Required Props
These props are required for the component to function:Your Termix project identifier. You can find this in your Termix dashboard under project settings.
AI configuration identifier that defines the model, prompts, and behavior settings for your AI assistant.
Authentication & API
Configure how the component connects to your backend services:Authorization header value for API requests. Typically a Bearer token.Example:
Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Additional headers to include with all API requests.
Custom headers object for REST function execution.
UI Customization
Control the appearance and text of the chat interface:Optional override for personality name (overrides API config value).
Placeholder text shown in the message input field.
Text displayed on the send button. Empty string shows default icon instead of text.
Fallback model name if API config fetch fails.
Feature Toggles
Enable or disable specific functionality: Note: Knowledge base, function calls, ReAct pattern, and knowledge references are now enabled by default and cannot be disabled.Enable real-time streaming responses using Server-Sent Events (SSE). Messages appear character-by-character as they’re generated.Note: Requires proper SSE endpoint configuration. See Streaming Mode guide for setup details.
Show/hide the chat header with AI model name and personality information. Features blue gradient background with white text.
Display token usage and cost information for each message. Also shows total cost in header when
showHeader
is enabled.Show timestamps on messages.
Maximum number of knowledge base results to display for each query.
Styling Props
Customize the visual appearance using CSS classes:Additional CSS classes for the main chat container.
CSS classes for the messages area container.
CSS classes for the message input field.
Event Callbacks
Handle events and customize behavior with callback functions:Called when a user sends a message.
Called when the AI responds with a message.
Called when a function call is executed (API call, smart contract, etc.).
Called when an error occurs during operation.
ChatWidget Configuration
When using theChatWidget
component, these additional props are available:
Dialog header title displayed at the top of the chat widget.
Custom button icon URL. When not specified, uses the default chat icon.
CSS classes for the floating chat button.
CSS classes for the chat dialog container.
Whether the dialog should be open by default when the component mounts.
Callback function called when the dialog open state changes.
ChatWidget Example
Complete Configuration Example
Here’s an example with all major configuration options:Environment-Specific Configurations
Important Changes in Latest Version
Automatic Feature Enablement
The following features are now enabled by default and cannot be disabled:- Knowledge Base Integration: Automatically searches and references knowledge base
- Function Calls: AI can execute REST APIs and smart contracts
- ReAct Pattern: Reasoning and acting pattern for complex tasks
- Knowledge References: Always displays knowledge base references when available
Welcome Message and Personality from API
The component now automatically fetches configuration from the AI config API:- Welcome Message: Uses greeting from API config or generates default
- Personality Name: Uses name from API config, can be overridden with
personalityName
prop - Re-fetching: Automatically re-fetches when
projectId
oraiConfigId
changes
"Hello! I'm [personality name]. How can I help you today?"
Default Values Changed
showUsageInfo
: Now defaults tofalse
(wastrue
)showTimestamp
: Now defaults tofalse
(wastrue
)- Knowledge references are always shown (removed
showKnowledgeReferences
prop)
Best Practices
Security: Never hardcode sensitive information like API keys or tokens in your frontend code. Use environment variables and server-side proxies.
Performance: Disable features you don’t need (like
showUsageInfo
in production) to reduce overhead.User Experience: Provide clear welcome messages and placeholders that guide users on what they can do.
Make sure to handle errors gracefully using the
onError
callback to provide good user experience when things go wrong.