Chat

Interactive chat component that displays messages between multiple participants with support for user input, message history, and various chat scenarios.

chatmessagingconversationassistantuser-interactionmulti-participant
v0.100.1
Promptbook Team

Live Preview

Features

  • Real-time message display with scrolling
  • Multi-participant support with custom avatars and colors
  • User message input with send functionality
  • Chat reset capability
  • Loading/typing indicators
  • Voice call integration
  • Rating system for assistant messages
  • Responsive design for mobile and desktop

Usage Examples

Empty Chat

<Chat messages={[]} participants={participants} onMessage={handleMessage} />

Simple User-Assistant Chat

<Chat 
    messages={[
        { id: '1', from: 'USER', content: 'Hello!', date: new Date(), isComplete: true },
        { id: '2', from: 'ASSISTANT', content: 'Hi! How can I help?', date: new Date(), isComplete: true }
    ]} 
    participants={participants}
    onMessage={handleMessage}
    onReset={handleReset}
/>

Multi-Participant Chat

<Chat 
    messages={multiParticipantMessages}
    participants={[
        { name: 'USER', fullname: 'You', isMe: true, color: '#3b82f6' },
        { name: 'ASSISTANT_1', fullname: 'AI Assistant', color: '#10b981' },
        { name: 'ASSISTANT_2', fullname: 'Code Helper', color: '#f59e0b' }
    ]}
    onMessage={handleMessage}
    placeholderMessageContent="Ask multiple assistants..."
/>

Chat with Loading Message

<Chat 
    messages={[
        { id: '1', from: 'USER', content: 'Question?', date: new Date(), isComplete: true },
        { id: '2', from: 'ASSISTANT', content: 'Thinking...', date: new Date(), isComplete: false }
    ]}
    participants={participants}
    onMessage={handleMessage}
/>

Quick Actions

Technical Details

Category

Chat

Dependencies

react: ^18.0.0 || ^19.0.0
@promptbook/components: 0.100.1

Props

messages
ReadonlyArray<ChatMessage>
Array of chat messages to display
participants
ReadonlyArray<ChatParticipant>
List of chat participants with their information (name, avatar, color, etc.)
onMessage
(messageContent: string) => Promise<void>
Callback function called when user sends a new message
onReset
() => Promise<void>
Optional callback to reset/clear the chat
placeholderMessageContent
string
Placeholder text for the message input field
Default: "Write a message"
defaultMessage
string
Optional preset message content in the input field
children
ReactNode
Optional content to show in the chat header bar
className
string
Optional CSS class name for styling
style
CSSProperties
Optional inline CSS styles
isVoiceRecognitionButtonShown
boolean
Whether to show the voice recognition button
Default: false
voiceLanguage
string
Language code for voice recognition
Default: "en-US"
isVoiceCalling
boolean
Whether a voice call is currently active
Default: false
Promptbook Components Gallery