Messages

A message is a piece of text, an image or a location that a user can send to a conversation.

Message data

FieldTypeDescription
id
stringRead-only. A unique ID for the message, generated by TalkJS.
Example: "msg_6TKoWs0Jm8XrjPOmFdOGiX"
conversationId
stringID of the Conversation this message was sent to.
type
"UserMessage"Always set to "UserMessage" for regular user messages. For system messages, see: System messages.
senderId
stringThe user ID of the sender.
readBy
string[]Read-only. List of the user IDs who have already read and received this message. Doesn't include the sender.

Example: ["123465", "654321"]

The readBy field is only used for conversations with at most 300 participants. For conversations with 301 or more participants, the readBy field is empty.

text
stringThe text of the message. Only given if this message is a text message.
attachment
{ url: string, size: number }Read-only. Only given if this message is a file transfer. An object with the location and filesize (in bytes) of the given file. Read how to send a file using the REST API
location
number[]An array of two numbers which represent the longitude and latitude of this location, respectively. Only given if this message is a shared location.
Example: [51.481083, -3.178306]
origin
"web" | "rest" | "email" | "import"Determines how this message was sent: respectively, Via a web browser (or mobile Webview), via the REST API, via reply-to-email, or using the import API.
createdAt
numberTimestamp when this message was sent, expressed as the amount of milliseconds since the UNIX epoch (1970-1-1, 00:00:00 UTC).
Example: 1525249255419
editedAt
numberTimestamp when this message was edited, expressed as the amount of milliseconds since the UNIX epoch (1970-1-1, 00:00:00 UTC).
Example: 1525249255419
referencedMessageId
string | nullID that refers to the message referred to by a reply. Referencing a message can be done via TalkJS UI.
custom
object of stringsAn object with key-value pairs (keys and values must be strings) that you want to associate with a message. TalkJS doesn't process this data at all, but you can access it in API responses, webhook events, and themes, among other places.

Further reading