Working with messages
Working with messages
For each server notification (request), the client should respond as follows:
{
"type": 2,
"id": 123456
}Once the response is sent, the user’s message is marked as read by the bot and a check mark appears in the TrueConf client application.
Client requests
Send message
Request:
{
"type": 1,
"id": 1,
"method": "sendMessage",
"payload": {
"chatId": "c8c3eee8-9ad0-4638-9692-ad16391a4256",
"content": {
"text": "Hello, world!",
"parseMode": "text"
}
}
}| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| type | uint32 | Yes | Message type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST |
| id | uint32 | Yes | Unique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here. |
| method | string | Yes | The sendMessage command |
| chatId | string | Yes | Chat ID |
| replyMessageId | string | No | If we are replying to a message, the field must contain the identifier of that message (see example below). |
| text | string | Yes | Message text |
| parseMode | string | Yes | Formatting mode (more details) |
Response:
{
"type": 2,
"id": 1,
"payload": {
"chatId": "c8c3eee8-9ad0-4638-9692-ad16391a4256",
"messageId": "8fe61d87-6db0-4792-8f5e-e5960c7d5a06",
"timestamp": 1735314170572
}
}| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| type | uint32 | Yes | Message type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE |
| id | uint32 | Yes | An identifier matching the number sent in the original request, used to link the request and response. |
| chatId | string | Yes | Chat ID to which the message was sent |
| messageId | string | Yes | Message ID. This identifier can be used later to modify, forward, or delete the message. |
| timestamp | uint64 | Yes | Timestamp of message sent in UNIX timestamp format with millisecond precision |
In the event of an error, a message containing the errorCode parameter is returned. A list of possible values is available in the corresponding section of the documentation.
Reply to message
To reply to an existing message, you need to fill in the replyMessageId field with the identifier of the message you are responding to:
{
"type": 1,
"id": 1,
"method": "sendMessage",
"payload": {
"chatId": "c8c3eee8-9ad0-4638-9692-ad16391a4256",
"replyMessageId": "3d968a21-543c-4fb2-9d8e-e31e3fbb35eb",
"content": {
"text": "Hello, world!",
"parseMode": "text"
}
}
}Edit message
Request:
{
"type": 1,
"id": 1,
"method": "editMessage",
"payload": {
"messageId": "8fe61d87-6db0-4792-8f5e-e5960c7d5a06",
"content": {
"text": "Hello, world (edited)!",
"parseMode": "text"
}
}
}| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| type | uint32 | Yes | Message type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST |
| id | uint32 | Yes | Unique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here. |
| method | string | Yes | Command editMessage |
| messageId | string | Yes | Text message ID |
| text | string | Yes | Message text |
| parseMode | string | Yes | Formatting mode (more details) |
Response:
{
"type": 2,
"id": 1,
"payload": {
"messageId": "8fe61d87-6db0-4792-8f5e-e5960c7d5a06",
"timestamp": 1735314170572
}
}| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| type | uint32 | Yes | Message type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE |
| id | uint32 | Yes | An identifier matching the number sent in the original request, used to link the request and response. |
| timestamp | uint64 | Yes | Timestamp of the message edit in UNIX timestamp format with millisecond precision. |
| messageId | string | Yes | Edited message ID |
In the event of an error, a message containing the errorCode parameter is returned. A list of possible values is available in the corresponding section of the documentation.
Forward message
Request:
{
"type": 1,
"id": 1,
"method": "forwardMessage",
"payload": {
"chatId": "4a1f88f1070d2f43d385cde9ff61964bc6b74477",
"messageId": "8fe61d87-6db0-4792-8f5e-e5960c7d5a06"
}
}| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| type | uint32 | Yes | Message type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST |
| id | uint32 | Yes | Unique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here. |
| method | string | Yes | Command forwardMessage |
| chatId | string | Yes | Chat ID to which you will forward the message |
| messageId | string | Yes | Forwarded message ID |
Response:
{
"type": 2,
"id": 1,
"payload": {
"chatId": "4a1f88f1070d2f43d385cde9ff61964bc6b74477",
"messageId": "3e168850-d9ea-45ec-a0f7-21c43e8ba2a8",
"timestamp": 1735314170572
}
}| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| type | uint32 | Yes | Message type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE |
| id | uint32 | Yes | An identifier matching the number sent in the original request, used to link the request and response. |
| chatId | string | Yes | Unique identifier of the chat to which the message was forwarded |
| messageId | string | Yes | Unique identifier of the new message containing your forwarded message |
| timestamp | uint64 | Yes | Message forwarding timestamp in UNIX timestamp format with millisecond precision |
In the event of an error, a message containing the errorCode parameter is returned. A list of possible values is available in the corresponding section of the documentation.
Delete message
Request:
{
"type": 1,
"id": 1,
"method": "removeMessage",
"payload": {
"messageId": "8fe61d87-6db0-4792-8f5e-e5960c7d5a06",
"forAll": true
}
}| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| type | uint32 | Yes | Message type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST |
| id | uint32 | Yes | Unique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here. |
| method | string | Yes | The removeMessage command |
| messageId | string | Yes | ID of the message to be deleted |
| forAll | boolean | Yes | If true, the message will be deleted for everyone |
Response:
{
"type": 2,
"id": 1,
"payload": {}
}| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| type | uint32 | Yes | Message type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE |
| id | uint32 | Yes | An identifier matching the number sent in the original request, used to link the request and response. |
| payload | object | Yes | In case of success, you will receive an empty object. |
In the event of an error, a message containing the errorCode parameter is returned. A list of possible values is available in the corresponding section of the documentation.
Retrieve message by ID
Request:
{
"type": 1,
"id": 1,
"method": "getMessageById",
"payload": {
"messageId": "8fe61d87-6db0-4792-8f5e-e5960c7d5a06"
}
}| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| type | uint32 | Yes | Message type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST |
| id | uint32 | Yes | Unique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here. |
| method | string | Yes | Command getMessageById |
| messageId | string | Yes | Requested message ID |
Response:
{
"id": 2,
"type": 2,
"payload": {
"chat": {
"chatId": "db445c1cf948976c98fd71633d968697fcab9d2f",
"chatTitle": "Colleagues",
"chatType": 2
},
"chatId": "db445c1cf948976c98fd71633d968697fcab9d2f",
"messageId": "85c4005b-25d7-407a-8b1c-c6a74cc993ca",
"timestamp": 1790634261078,
"author": {
"id": "john_doe@video.example.net",
"type": 1
},
"replyMessage": {
"chat": {
"chatId": "db445c1cf948976c98fd71633d968697fcab9d2f",
"chatTitle": "Colleagues",
"chatType": 2
},
"chatId": "db445c1cf948976c98fd71633d968697fcab9d2f",
"messageId": "eaa7a0ef-cbb7-46f1-ba80-b17e7eab80a7",
"timestamp": 1790343824882,
"author": {
"id": "john_doe@video.example.net",
"type": 1
},
"replyMessageId": "e0938239-5638-42ef-aeed-31d36f04743d",
"box": {
"id": 9,
"position": "0"
},
"type": 200,
"content": {
"text": "<quote class=\"reply\">corporate event</quote><br><br><b>Dear </b><b><i>colleagues</i></b><b>!</b> Details <u>can be found</u> through the link: <a href=\"https://example.com\">website</a>. Direct any questions to <a href=\"https://ceo.example.com\">management</a>!",
"parseMode": "html"
},
"isEdited": false
},
"replyMessageId": "eaa7a0ef-cbb7-46f1-ba80-b17e7eab80a7",
"box": {
"id": 11,
"position": "0"
},
"type": 200,
"content": {
"text": "reply to colleagues",
"parseMode": "html"
},
"isEdited": true
}
}The response contains an Envelope object in the payload field. Descriptions of fields and examples for various message types can be found in the "API Reference" section.
In the event of an error, a message containing the errorCode parameter is returned. A list of possible values is available in the corresponding section of the documentation.
Server notifications
New message
A message with the type 200 is a text message. The content field contains the message text, and the parseMode parameter determines how it is interpreted – HTML.
Notification from the server:
```json
{
"method": "sendMessage",
"type": 1,
"id": 5,
"payload": {
"chat": {
"chatId": "db445c1cf948976c98fd71633d968697fcab9d2f",
"chatTitle": "Colleagues",
"chatType": 2
},
"chatId": "db445c1cf948976c98fd71633d968697fcab9d2f",
"messageId": "c0ed3cc2-eccf-4e4f-9b0a-a242794d3ff3",
"timestamp": 1790634293677,
"author": {
"id": "john_doe@video.example.net",
"type": 1
},
"box": {
"id": 12,
"position": "0"
},
"type": 200,
"content": {
"text": "Hello!",
"parseMode": "html"
},
"isEdited": false
}
}The notification of a new message contains fields of the Envelope object. Descriptions of the fields and examples for various types of messages can be found in the “API Reference” section.
Response from client:
{
"type": 2,
"id": 123456
}| Field | Type | Mandatory | Description |
|---|---|---|---|
| type | uint32 | Yes | Message type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE |
| id | uint32 | Yes | Message ID being replied to (see more) |
Reply to message
When replying to a message, you will receive a payload with a replyMessage object (starting from 5.5.6+) and a replyMessageId parameter.
Notification from the server:
{
"method": "sendMessage",
"type": 1,
"id": 2,
"payload": {
"chat": {
"chatId": "db445c1cf948976c98fd71633d968697fcab9d2f",
"chatTitle": "Colleagues",
"chatType": 2
},
"chatId": "db445c1cf948976c98fd71633d968697fcab9d2f",
"messageId": "85c4005b-25d7-407a-8b1c-c6a74cc993ca",
"timestamp": 1790633677798,
"author": {
"id": "john_doe@video.example.net",
"type": 1
},
"replyMessage": {
"chat": {
"chatId": "db445c1cf948976c98fd71633d968697fcab9d2f",
"chatTitle": "Colleagues",
"chatType": 2
},
"chatId": "db445c1cf948976c98fd71633d968697fcab9d2f",
"messageId": "eaa7a0ef-cbb7-46f1-ba80-b17e7eab80a7",
"timestamp": 1790343824882,
"author": {
"id": "john_doe@video.example.net",
"type": 1
},
"replyMessageId": "e0938239-5638-42ef-aeed-31d36f04743d",
"box": {
"id": 9,
"position": "0"
},
"type": 200,
"content": {
"text": "Original message (being replied to)",
"parseMode": "html"
},
"isEdited": false
},
"replyMessageId": "eaa7a0ef-cbb7-46f1-ba80-b17e7eab80a7",
"box": {
"id": 10,
"position": "0"
},
"type": 200,
"content": {
"text": "Reply to the message",
"parseMode": "html"
},
"isEdited": false
}
}The notification of a new message contains fields of the Envelope object. Descriptions of the fields and examples for various types of messages can be found in the “API Reference” section.
Response from client:
{
"type": 2,
"id": 123456
}| Field | Type | Mandatory | Description |
|---|---|---|---|
| type | uint32 | Yes | Message type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE |
| id | uint32 | Yes | Message ID being replied to (see more) |
Forwarded message
A message with type 201 is identified as forwarded. The characteristic of the content of a forwarded message is that it contains the object of the forwarded message (Envelope) as its content, except for the data in the "box" field.
Theoretically, the chain of nested forwarded messages can be infinite, but currently, the nesting is limited to one message (Envelope).
The content field contains the original message object.
Notification from the server:
{
"method": "sendMessage",
"type": 1,
"id": 8,
"payload": {
"chatId": "d0b99ed24d6fb440a99fb12c4face5e5b28c3863",
"messageId": "b5feca9f-460b-43a4-8ae0-5f908544b16b",
"timestamp": 1776460454738,
"author": {
"id": "echo_bot@video.example.net",
"type": 1
},
"isEdited": false,
"box": {
"id": 14,
"position": "0"
},
"type": 201,
"content": {
"chat": {
"chatType": 2,
"chatTitle": "Group Chat",
"chatId": "e2cf0a56f8f8e4d263fec8536ea7b63c946939d9"
},
"chatId": "e2cf0a56f8f8e4d263fec8536ea7b63c946939d9",
"messageId": "73cc1e8b-b38b-4d3d-b6f1-c55682466d84",
"author": {
"id": "echo_bot@video.example.net",
"type": 1
},
"type": 202,
"isEdited": false,
"timestamp": 1776460454738,
"content": {
"name": "bot.log",
"mimeType": "text/plain",
"fileId": "c324bb1313fcc50099fbd2bfbb7251f79d473ed6",
"size": 186543
},
"box": {
"id": 14,
"position": "0"
}
}
}
}The notification of a new message contains fields of the Envelope object. Descriptions of the fields and examples for various types of messages can be found in the “API Reference” section.
Response from client:
{
"type": 2,
"id": 123456
}| Field | Type | Mandatory | Description |
|---|---|---|---|
| type | uint32 | Yes | Message type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE |
| id | uint32 | Yes | Message ID being replied to (see more) |
The message has been modified
Notification from the server:
{
"method": "editMessage",
"type": 1,
"id": 12,
"payload": {
"chatId": "d0b99ed24d6fb440a99fb12c4face5e5b28c3863",
"messageId": "d4d20b4f-e4a4-4abc-8e66-ff2e17f483b7",
"timestamp": 1746029430000,
"content": {
"text": "🤝",
"parseMode": "html"
}
}
}| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| method | string | Yes | Command editMessage |
| type | uint32 | Yes | Message type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST |
| id | uint32 | Yes | Unique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here. |
| chatId | string | Yes | Unique identifier of the chat containing the message |
| messageId | string | Yes | The identifier of the edited message. This identifier can be used later for copying, forwarding, or deleting the message. |
| timestamp | uint64 | Yes | Timestamp of message modification in UNIX timestamp format with millisecond precision |
| text | string | Yes | Edited message text |
| parseMode | string | Yes | Formatting mode (more details) |
Response from client:
{
"type": 2,
"id": 123456
}| Field | Type | Mandatory | Description |
|---|---|---|---|
| type | uint32 | Yes | Message type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE |
| id | uint32 | Yes | Message ID being replied to (see more) |
The message has been deleted
Notification from the server:
{
"method": "removeMessage",
"type": 1,
"id": 12,
"payload": {
"chatId": "bd05af54347e04a1c44e70033d35834d4428bb5d",
"messageId": "d4d20b4f-e4a4-4abc-8e66-ff2e17f483b7",
"removedBy": {
"id": "brown@video.example.com",
"type": 1
}
}
}| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| method | string | Yes | The removeMessage command |
| type | uint32 | Yes | Message type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST |
| id | uint32 | Yes | Unique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here. |
| chatId | string | Yes | Chat ID where the message was deleted |
| messageId | string | Yes | Remote message ID. This ID can be used for copying, forwarding, or deleting the message in the future. |
| removedBy.id | string | Yes | Unique identifier of the user who deleted the message. This could be either a TrueConf ID or the name of the server from which the message originated. The type of identifier depends on the removedBy.type field. |
| removedBy.type | uint32 | Yes | Type of user who deleted the message. For more details, see EnvelopeAuthorTypeEnum |
Response from client:
{
"type": 2,
"id": 123456
}| Field | Type | Mandatory | Description |
|---|---|---|---|
| type | uint32 | Yes | Message type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE |
| id | uint32 | Yes | Message ID being replied to (see more) |