Skip to main content

Chat

Ant Design

The Chat component shows a conversation between the user and a respondent, such as an AI assistant or a support agent, with a box for typing messages. The application sends each message to a query and adds the reply with the Append to history action.

Properties​

Property
Description
Expected Value
TitleHeading at the top of the chat.Text. Default: Assistant
HistoryMessages shown when the app loads, as a list of {message, type}, where type is message for the user and response for the respondent.Array
User nameName shown on the user's messages.Text. Default: You
User avatarImage URL of the user's avatar. When empty, the avatar shows the initials of User name.Text
Respondent nameName shown on the respondent's messages.Text. Default: Assistant
Respondent avatarImage URL of the respondent's avatar. When empty, the avatar shows the initials of Respondent name.Text
PlaceholderHint shown in the message box while it is empty.Text. Default: Type a message
Empty textMessage shown when the chat has no messages.Text. Default: No messages yet
Show avatarsShows an avatar beside each group of messages.On or off. Default: On
Show timestampsShows the time each message was sent.On or off. Default: On
Clear buttonShows a button in the header that clears all messages.On or off. Default: Off
Download buttonShows a button in the header that downloads the conversation as a JSON file.On or off. Default: Off
Response loadingShows typing dots from the respondent, while a reply is on its way.On or off. Default: Off
History loadingShows a spinner in place of the messages, while past messages load.On or off. Default: Off
Input disabledStops the user from typing and sending messages.On or off. Default: Off

Additional Actions​

Each of these can be switched on or off, or set with a logical expression by clicking fx.

Property
Description
Expected Value
VisibilityShows or hides the component. Hidden components keep their space unless Collapse when hidden is on.On or off. Default: On
Collapse when hiddenRemoves the hidden component's space, so the components below it move up.On or off. Default: Off
Loading stateShows the component's loading look and blocks interaction, for example while a query runs.On or off. Default: Off
DisableStops the user from interacting with the component.On or off. Default: Off

Devices​

Property
Description
Expected Value
Show on desktopShows the component in the desktop layout.On or off. Default: On
Show on mobileShows the component in the mobile layout.On or off. Default: Off

Events​

Add a handler from the Events section of the properties panel. See Event Triggers for the steps.

Event
Description
On message sentTriggers when the user sends a message, by pressing Enter or the send button, or when the Send message action runs.
On clear historyTriggers when the messages are cleared, by the clear button or the Clear history action.

Component Specific Actions (CSA)​

Run these from an event handler with Control Component, or from a RunJS query. See Component Specific Actions.

Action
Description
How To Access
Send messageSends the given Message as the user and fires On message sent.components.chat1.sendMessage("")
Append to historyAdds one or more messages to the conversation, as text or {message, type}. Plain text is added as a respondent's reply.components.chat1.appendHistory("")
Set historyReplaces the whole conversation with the given History, a list of {message, type}.components.chat1.setHistory("")
Clear historyRemoves all messages and fires On clear history.components.chat1.clearHistory()
Download chatDownloads the conversation as a JSON file.components.chat1.downloadChat()
Set response loadingShows or hides the respondent's typing dots.components.chat1.setResponseLoading("")
Set history loadingShows or hides the loading spinner in place of the messages.components.chat1.setHistoryLoading("")
Disable inputTurns the message box off or on.components.chat1.setInputDisable("")
Set user avatarChanges the user's avatar to the image at the given Avatar URL.components.chat1.setUserAvatar("")
Set respondent avatarChanges the respondent's avatar to the image at the given Avatar URL.components.chat1.setResponderAvatar("")
Set visibilityShows the component when true, hides it when false.components.chat1.setVisibility(false)
Set disableDisables the component when true, enables it when false.components.chat1.setDisable(false)
Set loadingTurns the loading state on with true, off with false.components.chat1.setLoading(false)

Exposed Variables​

Variable
Description
How To Access
titleHeading at the top of the chat.{{components.chat1.title}}
initialChatMessages shown when the app loads, as a list of {message, type}, where type is message for the user and response for the respondent.{{components.chat1.initialChat}}
userNameName shown on the user's messages.{{components.chat1.userName}}
userAvatarImage URL of the user's avatar. When empty, the avatar shows the initials of User name.{{components.chat1.userAvatar}}
respondentNameName shown on the respondent's messages.{{components.chat1.respondentName}}
respondentAvatarImage URL of the respondent's avatar. When empty, the avatar shows the initials of Respondent name.{{components.chat1.respondentAvatar}}
placeholderHint shown in the message box while it is empty.{{components.chat1.placeholder}}
emptyTextMessage shown when the chat has no messages.{{components.chat1.emptyText}}
showAvatarsShows an avatar beside each group of messages.{{components.chat1.showAvatars}}
showTimestampsShows the time each message was sent.{{components.chat1.showTimestamps}}
allowClearShows a button in the header that clears all messages.{{components.chat1.allowClear}}
allowDownloadShows a button in the header that downloads the conversation as a JSON file.{{components.chat1.allowDownload}}
responseLoadingShows typing dots from the respondent, while a reply is on its way.{{components.chat1.responseLoading}}
historyLoadingShows a spinner in place of the messages, while past messages load.{{components.chat1.historyLoading}}
inputDisabledStops the user from typing and sending messages.{{components.chat1.inputDisabled}}
historyAll messages in the conversation, each with message, type, name, avatar and timestamp.{{components.chat1.history}}
lastMessageThe last message the user sent.{{components.chat1.lastMessage}}
lastResponseThe last respondent message added to the conversation.{{components.chat1.lastResponse}}
isVisibleWhether the component is visible.{{components.chat1.isVisible}}
isLoadingWhether the component is in its loading state.{{components.chat1.isLoading}}
isDisabledWhether the component is disabled.{{components.chat1.isDisabled}}

Styles​

Style
Default
Primary colorTheme: Brand primary
Text colorTheme: Primary text
Container backgroundTheme: Surface 1
Border colorTheme: Default border
Border radius—
Box shadow0px 0px 0px 0px #00000040

A default that starts with Theme: follows the app's theme until the style is set to another value. See App Themes.