Views: 2046
Last Modified: 12.09.2024

Message "Like"

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.like', Array(

    'BOT_ID' => 39, // ID of chatbot that sends request. Is optional, there is only one chatbot
    'MESSAGE_ID' => 1, // Message ID (any message, sent in personal dialogues or in group chats, where chatbot is located)
    'ACTION' => 'auto' // Action, connected with method: plus – click «Like»; minus – «Like» is removed; auto – automatic calculation, tick should/shouldn't be specified. If not specified, it will work in auto mode 

), $_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.
WITHOUT_CHANGES After «Like» status call, it did not change.




Courses developed by Bitrix24