Working with Messages

TrueConfAbout 20 min

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.

Formatting Messages

The chat bot API supports three message formatting types:

  • text – plain text. All characters will be preserved and displayed.
  • markdown - basic Markdown formatting is supported. Special characters are converted into formatted text (bold, italic, links, etc.);
  • html - HTML tags will be interpreted and displayed as formatted text.

Markdown

Supported Markdown syntax:

StyleSyntaxExampleDisplayed text
Bold** or __**bold text**bold text
Italic* or _italic textitalic text
Strikethrough~~~~strikethrough text~~strikethrough text
Link[Text](https://url)[Website](https://example.com)Website

HTML

Supported HTML markup syntax:

TagExample of HTMLDisplayed text
<b><b>bold text</b>bold text
<i><i>italic text</i>italic text
s<s>strikethrough text</s>strikethrough text
<u><u>underlined text</u>underlined text
<a><a href="https://example.com">Website</a>Website

All additional tag attributes will be removed. For example, the HTML code:

<i style="position: fixed; top:0">Hacked!</i>

will be converted to:

<i>Hacked!</i>

User mention (mention) 5.5.3+

You can mention any server user using the following format:

markdown
[John Doe](trueconf:john_doe@video.example.com)

If a user is a member of a group chat or channel, they will receive a notification through a mention (@) even if the chat is muted.

Client Requests

Send message

Request:

{
  "type": 1,
  "id": 1,
  "method": "sendMessage",
  "payload": {
    "chatId": "c8c3eee8-9ad0-4638-9692-ad16391a4256",
    "content": {
      "text": "Hello, world!",
      "parseMode": "text"
    }
  }
}
ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST
iduint32YesUnique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here.
methodstringYesThe sendMessage command
chatIdstringYesChat ID
replyMessageIdstringNoIf we are replying to a message, the field must contain the identifier of that message (see example below).
textstringYesMessage text
parseModestringYesFormatting mode (see above)

Response:

{
  "type": 2,
  "id": 1,
  "payload": {
    "chatId": "c8c3eee8-9ad0-4638-9692-ad16391a4256",
    "messageId": "8fe61d87-6db0-4792-8f5e-e5960c7d5a06",
    "timestamp": 1735314170572
  }
}
ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE
iduint32YesAn identifier matching the number sent in the original request, used to link the request and response.
chatIdstringYesChat ID to which the message was sent
messageIdstringYesMessage ID. This identifier can be used later to modify, forward, or delete the message.
timestampuint64YesTimestamp 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"
    }
  }
}
ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST
iduint32YesUnique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here.
methodstringYesCommand editMessage
messageIdstringYesText message ID
textstringYesMessage text
parseModestringYesFormatting mode (see above)

Response:

{
    "type": 2,
    "id": 1,
    "payload": {
        "messageId": "8fe61d87-6db0-4792-8f5e-e5960c7d5a06",
        "timestamp": 1735314170572
    }
}
ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE
iduint32YesAn identifier matching the number sent in the original request, used to link the request and response.
timestampuint64YesTimestamp of the message edit in UNIX timestamp format with millisecond precision.
messageIdstringYesEdited 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"
    }
}
ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST
iduint32YesUnique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here.
methodstringYesCommand forwardMessage
chatIdstringYesChat ID to which you will forward the message
messageIdstringYesForwarded message ID

Response:

{
    "type": 2,
    "id": 1,
    "payload": {
        "chatId": "4a1f88f1070d2f43d385cde9ff61964bc6b74477",
        "messageId": "3e168850-d9ea-45ec-a0f7-21c43e8ba2a8",
        "timestamp": 1735314170572
    }
}
ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE
iduint32YesAn identifier matching the number sent in the original request, used to link the request and response.
chatIdstringYesUnique identifier of the chat to which the message was forwarded
messageIdstringYesUnique identifier of the new message containing your forwarded message
timestampuint64YesMessage 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
    }
}
ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST
iduint32YesUnique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here.
methodstringYesThe removeMessage command
messageIdstringYesID of the message to be deleted
forAllbooleanYesIf true, the message will be deleted for everyone

Response:

{
  "type": 2,
  "id": 1,
  "payload": {}
}
ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE
iduint32YesAn identifier matching the number sent in the original request, used to link the request and response.
payloadobjectYesIn 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.

Get message by ID

Request:

{
    "type": 1,
    "id": 1,
    "method": "getMessageById",
    "payload": {
        "messageId": "8fe61d87-6db0-4792-8f5e-e5960c7d5a06"
    }
}
ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST
iduint32YesUnique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here.
methodstringYesCommand getMessageById
messageIdstringYesRequested message ID

Response:

{
    "type": 2,
    "id": 1,
    "payload": {
        "chatId": "2b896a6ef210d6b2dcaebc2186c9a7974d616054",
        "messageId": "8fe61d87-6db0-4792-8f5e-e5960c7d5a06",
        "timestamp": 1234567890,
        "author": {
            "id": "user@video.example.com",
            "type": 1
        },
        "replyMessageId": null,
        "isEdited": true,
        "box": {
            "id": 123456,
            "position": "0"
        },
        "type": 0,
        "content": {
            "text": "Hello, chat bot!",
            "parseMode": "html"
        }
    }
}

ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE
iduint32YesAn identifier matching the number sent in the original request, used to link the request and response.
chatIdstringYesUnique identifier of the chat containing the message
messageIdstringYesUnique message identifier
timestampuint64YesTimestamp of message sent in UNIX timestamp format with millisecond precision
replyMessageIdstringNoIf this is a reply to a message, it contains the identifier of that message.
isEditedbooleanYesHas the message ever been edited
payload.typeuint32YesType of embedded message. For more details, see EnvelopeContentType.
author.idstringYesUnique identifier of the message author. This can either be the TrueConf ID of the user or the name of the server from which the message was sent. The type of identifier depends on the type field.
author.typeuint32YesMessage author type. For more details, see EnvelopeAuthorTypeEnum.
box.idnumberYesSerial number of the "box" containing the message. For more details, refer to the relevant section.
box.positionstringYesSequential number of the message in the "box". For more details, see the relevant section.

Depending on the value of payload.type, the payload.content object may contain data in one of the following formats:

Text message

Used when the message contains only text information.

ParameterTypeMandatoryDescription
textstringYesMessage text
parseModestringYesFormatting mode (see above)

Attachment (file)

Used when the message contains a file (document, image, etc.).

ParameterTypeMandatoryDescription
namestringYesFilename
sizenumberYesFile size
mimeTypestringYesMIME type of the file
fileIdstringYesFile ID on the server

Geolocation 5.5.3+

ParameterTypeMandatoryDescription
latitudenumberYesLatitude
longitudenumberYesLongitude
titlestringYesText description of the location. Usually, the address

Forwarded message

Represents an embedded message containing one of the structures described above (text, attachment, etc.) along with additional fields containing metadata. Structurally similar to a regular message, it includes author, timestamp, content, and other fields.

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.

Get chat history

Request:

{
    "type": 1,
    "id": 1,
    "method": "getChatHistory",
    "payload": {
        "chatId": "4a1f88f1070d2f43d385cde9ff61964bc6b74477",
        "count": 9999,
        "fromMessageId": "e37cfc52-592f-453f-a3dd-275170b2018d"
    }
}
ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST
iduint32YesUnique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here.
methodstringYesCommand getChatHistory
chatIdstringYesThe chat ID for which the message history is requested.
countuint32YesNumber of messages returned in the response
fromMessageIdstringNoChat message identifier from which the history will be returned.

Response:

{
    "type": 2,
    "id": 1,
    "payload": {
        "chatId": "4a1f88f1070d2f43d385cde9ff61964bc6b74477",
        "count": 1,
        "messages": [
            {
                "messageId": "8fe61d87-6db0-4792-8f5e-e5960c7d5a06",
                "timestamp": 1234567890,
                "author": {
                    "id": "user@video.example.com",
                    "type": 1
                },
                "replyMessageId": null,
                "isEdited": true,
                "box": {
                    "id": 123456,
                    "position": ""
                },
                "type": 0,
                "content": {
                    "text": "Hello, chat bot!",
                    "parseMode": "html"
                }
            }
        ]
    }
}
ParameterTypeMandatoryDescription
typeuint32YesMessage type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE
iduint32YesAn identifier matching the number sent in the original request, used to link the request and response.
chatIdstringYesChat ID for which the message history was requested
countuint32YesNumber of received messages
messagesArray<Envelope>NoAn array of Envelope objects, each representing a single message. See the parameter description above.

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 type 200 is a text message. The content field contains the message text, and the parseMode parameter determines how it is interpreted (e.g., Markdown or HTML).

Notification from the server:

{
  "method": "sendMessage",
  "type": 1,
  "id": 11,
  "payload": {
      "chatId": "bd05af54347e04a1c44e70033d35834d4428bb5d",
      "messageId": "d66254de-9d89-4130-8027-c5378f042800",
      "timestamp": 1746029007569,
      "author": {
          "id": "brown@video.example.com",
          "type": 1
      },
      "isEdited": false,
      "box": {
          "id": 4,
          "position": "0"
      },
      "type": 200,
      "content": {
          "text": "Hello, world!,
          "parseMode": "html"
      }
    }
}

The new message notification contains fields corresponding to the Envelope object. A detailed description of these fields can be found in the section dedicated to message handling.

Response from client:

{
    "type": 2,
    "id": 123456
}
FieldTypeMandatoryDescription
typeuint32YesMessage type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE
iduint32YesMessage ID being replied to (see more)

Reply to message

When replying to a message, you will receive a payload with the replyMessageId parameter.

Notification from the server:

{
  "method": "sendMessage",
  "type": 1,
  "id": 11,
  "payload": {
      "chatId": "bd05af54347e04a1c44e70033d35834d4428bb5d",
      "messageId": "d66254de-9d89-4130-8027-c5378f042800",
      "timestamp": 1746029007569,
      "author": {
          "id": "brown@video.example.com",
          "type": 1
      },
      "replyMessageId": "0c4dc725-ee33-4b91-9543-e4149e5d3ad3",
      "isEdited": false,
      "box": {
          "id": 4,
          "position": "0"
      },
      "type": 200,
      "content": {
          "text": "Hello., world!,
          "parseMode": "html"
      }
  }
}

The new message notification contains fields corresponding to the Envelope object. A detailed description of these fields can be found in the section dedicated to message handling.

Response from client:

{
    "type": 2,
    "id": 123456
}
FieldTypeMandatoryDescription
typeuint32YesMessage type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE
iduint32YesMessage ID being replied to (see more)

Forwarded message

A message with type 201 is identified as a forwarded message. 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": {
          "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 new message notification contains fields corresponding to the Envelope object. A detailed description of these fields can be found in the section dedicated to message handling.

Response from client:

{
    "type": 2,
    "id": 123456
}
FieldTypeMandatoryDescription
typeuint32YesMessage type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE
iduint32YesMessage ID being replied to (see more)

The message has been edited

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"
        }
    }
}
ParameterTypeMandatoryDescription
methodstringYesCommand editMessage
typeuint32YesMessage type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST
iduint32YesUnique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here.
chatIdstringYesUnique identifier of the chat containing the message
messageIdstringYesThe identifier of the edited message. This identifier can be used later for copying, forwarding, or deleting the message.
timestampuint64YesTimestamp of message modification in UNIX timestamp format with millisecond precision
textstringYesEdited message text
parseModestringYesFormatting mode (see details)

Response from client:

{
    "type": 2,
    "id": 123456
}
FieldTypeMandatoryDescription
typeuint32YesMessage type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE
iduint32YesMessage ID being replied to (see more)

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
        }
    }
}
ParameterTypeMandatoryDescription
methodstringYesThe removeMessage command
typeuint32YesMessage type (default is 1). Corresponds to MESSAGE_TYPE.REQUEST
iduint32YesUnique request identifier. An incremental value assigned by the sender, required in each request for subsequent association with the response. Read more here.
chatIdstringYesChat ID where the message was deleted
messageIdstringYesRemote message ID. This ID can be used for copying, forwarding, or deleting the message in the future.
removedBy.idstringYesUnique 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.typeuint32YesType of user who deleted the message. For more details, see EnvelopeAuthorTypeEnum

Response from client:

{
    "type": 2,
    "id": 123456
}
FieldTypeMandatoryDescription
typeuint32YesMessage type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE
iduint32YesMessage ID being replied to (see more)