Views: 1344
Last Modified: 13.05.2022

Deletes chatbot message

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.

Note: These methods of message processing are usually employed when the user is typing something, that is why the ONIMBOTMESSAGEADD event must be processed.

Method call

$result = restCommand('imbot.message.delete', Array(

    'BOT_ID' => 39, // ID of chatbot that sends request. Is optional, there is only one chatbot
    'MESSAGE_ID' => 1, // Message ID
    'COMPLETE' => 'N', //  If message is required to be deleted completely, without a trace, then specify 'Y' (optional parameter)

), $_REQUEST["auth"]);

Return

true or error.

Possible error codes

Code Description
BOT_ID_ERROR Chatbot not found.
APP_ID_ERROR Chatbot is not part of this application: you can only work with chatbots, installed within application framework.
MESSAGE_ID_ERROR Message ID was not transmitted.
CANT_EDIT_MESSAGE You do not have access to this message or time to modify it has expired (more than 3 days passed since publishing).




Courses developed by Bitrix24