Views: 3092
Last Modified: 23.03.2022

Modifies the 'message unread' status: all messages prior the specified message (but including the message itself) are marked as read

Revision Get current information about current API revision (platform version) – im.revision.get : 18

Attention: restCommand function is used here for illustration purposes only. It is taken from the EchoBot example. You can send a REST command with your own function, or use the BX24.callMethod or bitrix24-php-sdk methods.

Parameters

Parameter Example Req. Description Revision
DIALOG_ID chat29 Yes Dialog ID (chatXXX for chat and user ID for private dialog) 21
MESSAGE_ID 12 Yes The ID for the recent read chat message 21

Called method and response

JavaScript

BX24.callMethod('im.dialog.read', {
  'DIALOG_ID': chat29,
  'MESSAGE_ID': 12,
}, function(result){
  if(result.error())
  {
    console.error(result.error().ex);
  }
  else
  {
    console.log(result.data());
  }
});

PHP

$result = restCommand('im.dialog.read', Array(
  'DIALOG_ID' => chat29,
  'MESSAGE_ID' => 12,  
), $_REQUEST["auth"]);

Response example

{
  "result": true
} 
{
    "result": 
    {
        dialogId: "chat76", 
        chatId: 76, 
        counter: 1, 
        lastId: 6930
    }
} 
  • dialogId – read chat ID
  • chatId – chat ID
  • counter – number of unread messages after method execution
  • lastId – recent read message

When method is unable to set new read tag:

{
 "result": false
}

Examples of response with error

{
    "error": "MESSAGE_ID_ERROR",
    "error_description": "Message ID can't be empty"
}

Description of keys:

  • error – error code
  • error_description – brief error description

Possible error codes

Code Description
MESSAGE_ID_ERROR Incorrect message ID
DIALOG_ID_EMPTY Incorrect dialog ID



Courses developed by Bitrix24