Skip to main content

Chat

The chat module allows users to send messages to either the whole conference room, or to individual users.

Joining the room

JoinSuccess

When joining a room, the join_success control event contains the module-specific fields described below.

Fields

FieldTypeAlwaysDescription
enabledboolyesWhen true, the chat is enabled
room_historyStoredMessage[]yesChat history for the room
groups_historyGroupHistory[]yesChat history for each group
private_historyPrivateHistory[]yesChat history for a participant's private conversations
last_seen_timestamp_globalstringnoLast seen timestamp for the global chat
last_seen_timestamps_privatemapnoLast seen timestamps for private chats. Map key is the participant id.
last_seen_timestamps_groupmapnoLast seen timestamps for group chats. Map key is the group name.
Example
    ...
"room_history": [
{
"source": "00000000-0000-0000-0000-000000000000",
"scope": "global",
"content": "Hello all!",
"timestamp": "2023-01-13T12:37:08Z"
},
...
],
"groups_history": [
{
"history": [
{
"source": "00000000-0000-0000-0000-000000000000",
"scope": "group",
"target": "management",
"content": "Hello managers!",
"timestamp": "2023-01-13T12:37:08Z"
}
],
"name": "/OpenTalk/OU/Backend"
},
...
],
"private_history": [
{
"history": [
{
"source": "00000000-0000-0000-0000-000000000000",
"scope": "private",
"target": "00000000-0000-0000-0000-000000000001",
"content": "Hello private chat correspondent!",
"timestamp": "2023-01-13T12:37:08Z"
}
],
"correspondent": "00000000-0000-0000-0000-000000000000"
},
...
],
"last_seen_timestamp_global": "2023-01-03T12:34:56Z",
"last_seen_timestamps_private": {
"00000000-0000-0000-0000-000000000000": "2023-01-02T11:22:33Z"
},
"last_seen_timestamps_group": {
"/OpenTalk/OU/Backend": "2023-01-02T12:11:11Z",
"/OpenTalk/Role/Developer": "2023-01-02T12:10:23Z"
}
...

Joined

When joining a room, the joined control event sent to all other participants contains the module-specific fields described below.

Fields

FieldTypeAlwaysDescription
groupsstring[]yesGroups belonging to the participant
Example
    ...
"groups": [
"/OpenTalk/OU/Backend",
"/OpenTalk/Role/Developer",
...
]
...

Commands

EnableChat

Allows a moderator to enable the chat if it is currently disabled.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "enable_chat"
Example
{
"action": "enable_chat"
}

DisableChat

Allows a moderator to disable the chat if it is currently enabled.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "disable_chat"
Example
{
"action": "disable_chat"
}

SendMessage

Send a message to either the conference room (global message), a group or a specific user (direct message).

Fields

FieldTypeRequiredDescription
actionenumyesMust be "send_message"
scopeenumyesEither "global", "group" or "private"
targetstringnoNeeded if scope is "group" or "private". Participant id or group
contentstringyesThe message content
Example
{
"action": "send_message",
"scope": "global",
"content": "Hello all!"
}
{
"action": "send_message",
"scope": "group",
"target": "management",
"content": "Hello managers!"
}
{
"action": "send_message",
"scope": "private",
"target": "00000000-0000-0000-0000-000000000000",
"content": "Hello Bob!"
}

ClearHistory

Allows a moderator to clear the global chat history of the conference room.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "clear_history"
Example
{
"action": "clear_history"
}

SetLastSeenTimestamp

Set the last seen timestamp for either global chat messages, group or private messages with a specific participant.

The values that are set in SetLastSeenTimestamp, will be included in the chat field of module_data inside the JoinSuccess message when reconnecting to the same room after leaving.

Fields

FieldTypeRequiredDescription
actionenumyesMust be "set_last_seen_timestamp"
scopeenumyesEither "global", "group" or "private"
targetstringIf scope is "group" or "private"Participant id or group
timestampstringyesThe timestamp when the messages in the chat were last read
Example
{
"action": "set_last_seen_timestamp",
"scope": "global",
"timestamp": "2022-10-22T11:22:33Z"
}
{
"action": "set_last_seen_timestamp",
"scope": "group",
"target": "/OpenTalk/OU/Backend",
"timestamp": "2022-10-22T11:22:33Z"
}
{
"action": "set_last_seen_timestamp",
"scope": "private",
"target": "00000000-0000-0000-0000-000000000000",
"timestamp": "2022-10-22T11:22:33Z"
}

Events

MessageSent

A message has been sent to either the global chat or directly to the participant.

Fields

FieldTypeAlwaysDescription
messageenumyesIs "message_sent"
sourcestringyesId of the participant who sent the message
scopeenumyesEither "global", "group" or "private"
targetstringnoOnly if scope is "group" or "private". Participant id or group
contentstringyesThe message content
Example
{
"message": "message_sent",
"source": "00000000-0000-0000-0000-000000000000",
"scope": "global",
"content": "Hello all!"
}
{
"message": "message_sent",
"source": "00000000-0000-0000-0000-000000000000",
"scope": "group",
"target": "management",
"content": "Hello managers!"
}
{
"message": "message_sent",
"source": "00000000-0000-0000-0000-000000000000",
"scope": "private",
"target": "00000000-0000-0000-0000-0000deadbeef",
"content": "Hello Bob!"
}

Error

Received when something went wrong processing messages sent to the server.

Fields

FieldTypeAlwaysDescription
messageenumyesIs "error"
errorenumyesExhaustive list of error strings, see table below
ErrorDescription
chat_disabledA message was sent while the chat was disabled
insufficient_permissionsA moderator action was attempted by a non-moderator participant
{
"message": "error",
"error": "chat_disabled"
}