Working with messages

TrueConfAbout 16 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.

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 (more details)

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 (more details)

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.

Retrieve 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:

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:

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
}
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 a replyMessage object (starting from 5.5.6+) and a replyMessageId parameter.

Notification from the server:

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
}
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 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:

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
}
FieldTypeMandatoryDescription
typeuint32YesMessage type (default is 2). Corresponds to MESSAGE_TYPE.RESPONSE
iduint32YesMessage 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"
        }
    }
}
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 (more 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)

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
        }
    }
}
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)