Skip to main content

The Chat component for Retool Apps

An interface for AI chat conversations.

Properties

All properties for this object with supported data types or values. You can write JavaScript almost anywhere in Retool to manipulate or read property values.

assistantName

The name of the AI.

Type string
Format Plain Text
Mutability
ControlUsage
Retool UI Inspector
Default
Retool AI
Examples
"Retool AI"

avatarFallback

The text that is displayed when there is no Image URL or icon.

Type string
Format Plain Text
Mutability
ControlUsage
Retool UI Inspector
Examples
"Jenny Appleseed"

avatarIcon

The icon that's displayed for the avatar.

Type string
Format Icon Key
Mutability
ControlUsage
Retool UI Inspector
Examples
"/icon:bold/user"

avatarImageSize

The size of the avatar image.

Type string
Mutability
ControlUsage
Retool UI Inspector

avatarSrc

The image URL to use for the avatar.

Type string
Formaturl
Mutability
ControlUsage
Retool UI Inspector
Examples
"https://example.com/image.jpg"

data

The data.

Type array
Format Custom data
Mutability
ControlUsage
Retool UI Inspector
MethodcopyToClipboard()

disableSubmit

Whether to disable form submission.

Type boolean
Mutability
ControlUsage
Retool UI Inspector

emptyDescription

The description to display before the first message is sent.

Type string
Mutability
ControlUsage
Retool UI Inspector

emptyTitle

The title to display before the first message is sent.

Type string
Mutability
ControlUsage
Retool UI Inspector

hidden

Whether this object is hidden from view.

Type boolean
Format True/False
Mutability
ControlUsage
Retool UI Inspector > Appearance
MethodsetHidden()
Default
false
Examples
true

id

The unique identifier (name).

Type string
Format Plain Text
Mutability
ControlUsage
Retool UI Inspector
Default
chat1
Examples
query1
button1

lastMessage

The last message message sent by the user.

Type string
Mutability Read-only

lastResponse

The last response from the AI.

Type string
Mutability Read-only

messageHistory

A list of messages previously sent and received.

Type array
Array values string
Mutability Read-only

placeholder

The text to display within the input field when there is no value.

Type string
Formatstring
Mutability
ControlUsage
Retool UI Inspector > Content
Default
Enter a value
Examples
Enter a value

queryTargetId

The ID of the query to send messageHistory to.

Type string
Mutability
ControlUsage
Retool UI Inspector

showAvatar

Whether to display an avatar.

Type boolean
Mutability
ControlUsage
Retool UI Inspector

showEmptyState

Whether to display an empty state before a message is sent. Enabled by adding the Empty state add-on.

Type boolean
Mutability
ControlUsage
Retool UI Inspector

showHeader

Whether to show the header area.

Type boolean
Mutability
ControlUsage
Retool UI Inspector
MethodsetShowHeader()

showTimestamp

Whether to display a timestamp for messages.

Type array
Array values boolean
Mutability
ControlUsage
Retool UI Inspector

style

Custom style options.

Type object
Mutability
ControlUsage
Retool UI Inspector > Appearance

title

The title text to display.

Type string
Mutability
ControlUsage
Retool UI Inspector

value

The value.

Type string | number | boolean | object | array
Mutability Read-only

Methods

JavaScript API methods for this object. You can write JavaScript almost anywhere in Retool and use methods to manipulate data and property values.

chat.clearHistory()

Clear the history.

Definition
chat.clearHistory()
Examples

Clear the history from chat.

chat.clearHistory();

chat.clearValue()

Clear the current values.

Definition
chat.clearValue()
Examples

Clear the current value of chat.

chat.clearValue();

chat.exportData()

Exports data as a file in a CSV, TSV, JSON, or Excel format.

Definition
chat.exportData(options)
Parameters

options

unknown

chat.resetValue()

Reset the current value to the default value.

Definition
chat.resetValue()
Examples

Reset the current value of chat.

chat.resetValue();

chat.scrollIntoView()

Scrolls the canvas or parent container so that the selected component appears in the visible area.

Definition
chat.scrollIntoView(options)
Parameters

options Required

object

The scroll options.

Object Properties

behavior Required

string

The scroll behavior.

Supported Values
auto

Scroll immediately to the specified position.

smooth

Scroll gradually to the specified position.

block Required

string

The scroll position relative to the component.

Supported Values
nearest

Scrolls only the minimum amount required for the component to appear in the visible area. Scrolling does not occur if the component is already in view.

start

Scrolls to position the component at the top of the visible area.

center

Scrolls to position the component in the middle of the visible area.

end

Scrolls to position the component at the bottom of the visible area.

Examples

Scroll the minimum amount to immediately bring chat into view.

chat.scrollIntoView({behavior: 'auto', block: 'nearest'});

chat.sendMessage()

Send the current message.

Definition
chat.sendMessage()

chat.setHidden()

Set the hidden value to toggle whether the component is visible. Defaults to true without a parameter.

Definition
chat.setHidden(hidden)
Parameters

hidden

boolean

Whether this object is hidden from view.

Examples

Hide chat.

chat.setHidden(true);

Unhide chat.

chat.setHidden(false);

chat.setShowHeader()

Set the showHeader value to toggle whether the component header is visible.

Definition
chat.setShowHeader(showHeader)
Parameters

showHeader

boolean

Whether to show the header area.

Examples

Show the header of chat.

chat.setShowHeader(true);

Hide the header of chat.

chat.setShowHeader(false);

chat.setValue()

Set the current value.

Definition
chat.setValue(value)
Parameters

value

string | number | boolean | object | array

The value.

Examples

Set the current value of chat to userValue.

chat.setValue(userValue);

Events

Events triggered by user interactions. Use event handlers to trigger queries or other actions in response to events.