Overview

Basic ChatBot

This demo displays a basic ChatBot, which includes:

  1. The <ChatbotToggle> that controls the <Chatbot> container.
  2. A <ChatbotHeader> with all built sub-components laid out, including a <ChatbotHeaderTitle> that changes its presentation depending on the display mode.
  3. The ability to swap display modes via <ChatbotHeaderOptionsDropdown>
  4. <ChatbotContent> and <MessageBox> with:
  • A <ChatbotWelcomePrompt>
  • An initial user <Message> and an initial bot message with message actions.
  • Logic for enabling auto-scrolling to the most recent message whenever a new message is sent or received using a scrollToBottomRef
  1. A <ChatbotFooter> with a <ChatbotFootNote> and a <MessageBar> that contains the abilities of:
  • Speech to text.
  • Sending a message to the ChatBot.
  • Receiving a response from a backend AI tool with a loading message state.
  1. A <ChatbotConversationHistoryNav> toggled open and closed by the <ChatbotHeaderMenu> in the <ChatbotHeader>.

  2. A "Skip to chatbot" button that allows you to skip to the chatbot content via the PatternFly skip to content component. To display this button you must tab into the main window.

Basic ChatBot screenshot

Embedded ChatBot

This demo displays an embedded ChatBot. Embedded ChatBots are meant to be placed within a page in your product. This demo includes:

  1. A PatternFly page with a sidebar, "Skip to chatbot" button, and masthead. To display the "Skip to chatbot" button you must tab into the main window.
  2. A <Chatbot> container.
  3. A <ChatbotHeader> with all built sub-components laid out, including a <ChatbotHeaderTitle>
  4. <ChatbotContent> and <MessageBox> with:
    • A <ChatbotWelcomePrompt>
    • An initial user <Message> and an initial bot message with message actions.
    • Logic for enabling auto-scrolling to the most recent message whenever a new message is sent or received using a scrollToBottomRef
  5. A <ChatbotFooter> with a <ChatbotFootNote> and a <MessageBar> that contains the abilities of:
    • Speech to text.
    • Sending a message to the ChatBot.
    • Receiving a response from a backend AI tool with a loading message state.
  6. A <ChatbotConversationHistoryNav> that can be toggled by the <ChatbotHeaderMenu> in the <ChatbotHeader>.
Embedded ChatBot screenshot

Props

Chatbot

*required
NameTypeDefaultDescription
childrenrequiredReact.ReactNodeContent to be displayed in the chatbot
ariaLabelstringCustom aria label applied to focusable container
classNamestringCustom classname for the Chatbot component
displayModeChatbotDisplayModeDisplay Mode for the Chatbot
innerRefReact.Ref<HTMLDivElement>Ref applied to chatbot
isVisiblebooleanVisibility flag for the chatbot

ChatbotToggle

*required
NameTypeDefaultDescription
tooltipLabelrequiredReact.ReactNodeContents of the tooltip applied to the toggle button
classNamestringClass name applied to toggle
closedToggleIcon() => JSX.ElementAn image displayed in the chatbot toggle when it is closed
innerRefReact.Ref<HTMLButtonElement>Ref applied to toggle
isChatbotVisiblebooleanFlag indicating visibility of the chatbot appended to the toggle
isRoundbooleanWhether toggle is a circle
onToggleChatbot() => voidCallback fired when toggle button is clicked
openIconTestIdstringTest id applied to default open icon
toggleButtonLabelstringAccessible label for the toggle button
tooltipPropsOmit<TooltipProps, 'content'>Props spread to the PF Tooltip component

ChatbotContent

*required
NameTypeDefaultDescription
childrenrequiredReact.ReactNodeContent to be displayed in the chatbot
classNamestringCustom classname for the ChatbotContent component

ChatbotWelcomePrompt

*required
NameTypeDefaultDescription
descriptionrequiredstringWelcome message
titlerequiredstringTitle for the welcome message
classNamestringCustom classname for the WelcomePrompt component
promptsWelcomePrompt[]Custom basic prompts to help users coming for the first time to chatbot
testIdstringCustom test id for the WelcomePrompt component

ChatbotFooter

*required
NameTypeDefaultDescription
childrenReact.ReactNodeChildren for the Footer that supports MessageBar and FootNote components
classNamestringCustom classname for the Footer component

MessageBar

*required
NameTypeDefaultDescription
onSendMessagerequired(message: string) => voidCallback to get the value of input message by user
alwayShowSendButtonbooleanFlag to always to show the send button. By default send button is shown when there is a message in the input field
attachMenuPropsMessageBarWithAttachMenuPropsProps to enable a menu that opens when the Attach button is clicked, instead of the attachment window
buttonProps{ attach?: { tooltipContent?: string; props?: ButtonProps; inputTestId?: string }; stop?: { tooltipContent?: string; props?: ButtonProps }; send?: { tooltipContent?: string; props?: ButtonProps }; microphone?: { tooltipContent?: { active?: string; inactive?: string }; language?: string; props?: ButtonProps; }; }Prop to allow passage of additional props to buttons
classNamestringClass Name for the MessageBar component
handleAttach(data: File[], event: DropEvent) => voidCallback function for when attach button is used to upload a file
handleStopButton(event: React.MouseEvent<HTMLButtonElement>) => voidCallback function for when stop button is clicked
hasAttachButtonbooleantrueFlag to disable/enable the Attach button
hasMicrophoneButtonbooleanFlag to enable the Microphone button
hasStopButtonbooleanFlag to enable the Stop button, used for streaming content
isSendButtonDisabledbooleanFlag to provide manual control over whether send button is disabled
onChange(event: React.ChangeEvent<HTMLDivElement>, value: string) => voidA callback for when the text area value changes.

ChatbotFootnote

*required
NameTypeDefaultDescription
labelrequiredstringLabel to show for the footnote
classNamestringCustom classname for the Footnote component
popoverChatbotFootnotePopoverConfig for the popover which opens up when footnote is clicked

MessageBox

*required
NameTypeDefaultDescription
childrenrequiredReact.ReactNodeContent to be displayed in the message box
announcementstringContent that can be announced, such as a new message, for screen readers
ariaLabelstringCustom aria-label for scrollable portion of message box
classNamestringCustom classname for the MessageBox component
innerRefReact.Ref<HTMLDivElement>Ref applied to message box
position'top' | 'bottom'Modifier that controls how content in MessageBox is positioned within the container

Message

*required
NameTypeDefaultDescription
avatarrequiredstringAvatar src for the user
rolerequired'user' | 'bot'Role of the user sending the message
actions{ [key: string]: ActionProps; }Props for message actions, such as feedback (positive or negative), copy button, share, and listen
attachmentsMessageAttachment[]Array of attachments attached to a message
avatarPropsOmit<AvatarProps, 'alt'>Any additional props applied to the avatar, for additional customization
botWordstring'AI'Label for the English word "AI," used to tag messages with role "bot"
codeBlockProps{ 'aria-label'?: string; className?: string; }
contentstringMessage content
hasRoundAvatarbooleantrueWhether avatar is round
idstringUnique id for message
isLoadingbooleanSet this to true if message is being loaded
loadingWordstring'Loading message'Label for the English "Loading message," displayed to screenreaders when loading a message
namestringName of the user
quickResponseContainerPropsOmit<LabelGroupProps, 'ref'>{ numLabels: 5 }Props for quick responses container
quickResponsesQuickResponse[]Props for quick responses
sourcesSourcesCardPropsSources for message
timestampstringTimestamp for the message

MessageBarWithAttachMenuProps

*required
NameTypeDefaultDescription
attachMenuItemsrequiredReact.ReactNodeItems in menu
isAttachMenuOpenrequiredbooleanFlag to enable whether attach menu is open
onAttachMenuInputChangerequired(value: string) => voidA callback for when the input value in the menu changes.
onAttachMenuToggleClickrequired() => voidA callback for when the attachment menu toggle is clicked
setIsAttachMenuOpenrequired(isOpen: boolean) => voidCallback to close attach menu
attachMenuInputPlaceholderstringPlaceholder for search input
onAttachMenuOnOpenChangeKeysstring[]Keys that trigger onOpenChange, defaults to tab and escape. It is highly recommended to include Escape in the array, while Tab may be omitted if the menu contains non-menu items that are focusable.
onAttachMenuOpenChange(isOpen: boolean) => voidCallback to change the open state of the menu. Triggered by clicking outside of the menu.
onAttachMenuSelect(event?: React.MouseEvent<Element, MouseEvent>, value?: string | number) => voidFunction callback called when user selects item in menu.