Message

An object representing a TalkJS message.

Example

1{
2 "id": "msg_5fCIVedfUSBN2gx1jlyf9P",
3 "conversation": {
4 "id": "alice_self",
5 "custom": {},
6 "subject": null,
7 "welcomeMessages": null,
8 "photoUrl": null,
9 "participants": {
10 "650d5ed0cae49": {
11 "access": "ReadWrite"
12 }
13 }
14 },
15 "isByMe": true,
16 "senderId": "650d5ed0cae49",
17 "sender": {
18 "id": "650d5ed0cae49",
19 "name": "Alice",
20 "welcomeMessage": null,
21 "photoUrl": null,
22 "role": "default",
23 "custom": {},
24 "availabilityText": null,
25 "locale": null,
26 },
27 "body": "Hey",
28 "type": "text",
29 "timestamp": 1709134981992,
30 "read": true,
31 "origin": "web",
32 "custom": {},
33 "attachment": null,
34 "location": null
35}

Properties

NameTypeDescription
idstringThe message's ID
conversationConversationDataContains the conversation data that the message belongs to
isByMebooleantrue if the message was sent by the current user
senderIdstring | nullThe senderID (userID) for the person that sent the message
senderUserData | nullThe user that sent the message
bodystringContains the message's content
type"media" | "text" | "location"Specified if the message is media (file), text or a shared location
timestampnumberUNIX timestamp specifying when the message was sent (UTC, in milliseconds)
readbooleantrue if the message has been read, false when it hasn't been read yet
originstringDetermines how this message was sent: through a web browser (or mobile WebView), with the REST API, by reply-to-email, or using the import API
customCustomDataAllows you to set custom metadata for the Message. Set any property to null to delete the existing value, if any. When omitted or undefined, the existing value remains unchanged.
attachment{url: string; size: number} | nullOnly given if the message's type equals "media". An object with the URL and filesize (in bytes) of the given file.
location[number, number] | nullOnly given if the message's type equals "location". An array of two numbers which represent the longitude and latitude of this location, respectively. Only given if this message is a shared location.

Used by