Skip to main content

Types

There are 3 supported message types at the moment - File, Image and Text. All of them have corresponding "partial" message types, that include only the message's content. "Partial" messages are useful to create the content and then pass it to some kind of a backend service, which will assign fields like id or authorId etc, returning a "full" message which can be passed to messages prop of the <Chat />.

Base#

All messages should have this, most of these fields will be set by the backend service (you can set type and maybe an error or sending status).

note

Question mark shows optional types.

NameTypeDescription
authorIdstringMessage's author
idstringMessage's ID
status?delivered error read sendingMessage's status
timestamp?numberTimestamp in seconds
typefile image textMessage's type

Partial file#

NameTypeDescription
fileNamestringFile's name
mimeType?stringFile's MIME type
sizenumberSize in bytes
uristringSupports both local resource and remote URL

File#

File message is a combination of base and partial file types, where the base's type is set to file. This is what the chat expects in the messages array.

Partial image#

Even though height and width are optional, we recommend setting those (because you will anyway have them from the image picker) for a better overall look and feel, since the placeholder of this size will be rendered and when the image is available it will just replace it.

NameTypeDescription
height?numberImage's height
imageNamestringImage's name
sizenumberSize in bytes
uristringSupports both local resource and remote URL
width?numberImage's width

Image#

Image message is a combination of base and partial image types, where the base's type is set to image. This is what the chat expects in the messages array.

Partial text#

NameTypeDescription
previewData?PreviewDataYou shouldn't probably set this field directly, use onPreviewDataFetched callback
textstringText

Text#

Text message is a combination of base and partial text types, where the base's type is set to text. This is what the chat expects in the messages array.

User#

The only required field for the user is the id, used to determine the message author, however, you can pass additional data if you will want to render all available users for the chat or a conversation tile.

NameTypeDescription
avatarUrl?stringUser's avatar remote URL
firstName?stringUser's first name
idstringUnique ID
lastName?stringUser's last name