Event on Comment Addition OnTaskCommentAdd

If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect to the MCP server so that the assistant can utilize the official REST documentation.

Scope: task

Who can subscribe: any user

The event triggers after a new comment is added to a task.

Events will not be sent to the application until the installation is complete. Check the application installation

What the handler receives

Data is transmitted as a POST request

When working with the old task card prior to module version tasks 25.700.0:

array(
            'event' => 'ONTASKCOMMENTADD',
            'data' => array(
                'FIELDS_BEFORE' => 'undefined',
                'FIELDS_AFTER' => array('ID' => 123, 'TASK_ID' => 555),
                'IS_ACCESSIBLE_BEFORE' => 'undefined',
                'IS_ACCESSIBLE_AFTER' => 'undefined',
            ),
            'ts' => '1466439714',
            'auth' => array(
                'access_token' => 's6p6eclrvim6da22ft9ch94ekreb52lv',
                'expires_in' => '3600',
                'scope' => 'crm',
                'domain' => 'some-domain.bitrix24.com',
                'server_endpoint' => 'https://oauth.bitrix.info/rest/',
                'status' => 'F',
                'client_endpoint' => 'https://some-domain.bitrix24.com/rest/',
                'member_id' => 'a223c6b3710f85df22e9377d6c4f7553',
                'refresh_token' => '4s386p3q0tr8dy89xvmt96234v3dljg8',
                'application_token' => '51856fefc120afa4b628cc82d3935cce',
                ),
        )
        

When working with the new task card with chat from module version tasks 25.700.0:

array(
            'event' => 'ONTASKCOMMENTADD',
            'data' => array(
                'FIELDS_BEFORE' => 'undefined',
                'FIELDS_AFTER' => array('ID' => 0, 'TASK_ID' => 555, 'MESSAGE_ID' => 1458),
                'IS_ACCESSIBLE_BEFORE' => 'undefined',
                'IS_ACCESSIBLE_AFTER' => 'undefined',
            ),
            'ts' => '1466439714',
            'auth' => array(
                'access_token' => 's6p6eclrvim6da22ft9ch94ekreb52lv',
                'expires_in' => '3600',
                'scope' => 'crm',
                'domain' => 'some-domain.bitrix24.com',
                'server_endpoint' => 'https://oauth.bitrix.info/rest/',
                'status' => 'F',
                'client_endpoint' => 'https://some-domain.bitrix24.com/rest/',
                'member_id' => 'a223c6b3710f85df22e9377d6c4f7553',
                'refresh_token' => '4s386p3q0tr8dy89xvmt96234v3dljg8',
                'application_token' => '51856fefc120afa4b628cc82d3935cce',
                ),
        )
        

Required parameters are marked with *

Parameter
type

Description

event*
string

Symbolic event code, in this case OnTaskAdd

data*
array

Array with data of the new task comment

ts*
timestamp

Date and time of the event sent from the event queue

auth*
array

Authorization parameters and data about the account where the event occurred

Parameter data[]

Required parameters are marked with *

Name
type

Description

FIELDS_BEFORE*
undefined|object

Fields of the comment and task before the event (detailed description provided below). If there are no available task fields, this field will contain the value undefined

FIELDS_AFTER*
undefined|object

Fields of the comment and task after the event (detailed description provided below). If there are no available task fields, this field will contain the value undefined

IS_ACCESSIBLE_BEFORE*
string

Was the task readable before the event (detailed description provided below)

IS_ACCESSIBLE_AFTER*
string

Is the task readable after the event (detailed description provided below)

Field FIELDS_BEFORE

Required parameters are marked with *

Name
type

Description

ID*
integer

Identifier of the created comment. 'ID' => 0 is returned when the new task card is active from module version tasks 25.700.0

TASK_ID*
integer

Identifier of the task to which the comment was added

MESSAGE_ID
integer

Identifier of the sent message in the task chat, returned when the new task card is active from module version tasks 25.700.0

Field FIELDS_AFTER

Required parameters are marked with *

Name
type

Description

ID*
integer

Identifier of the created comment

TASK_ID*
integer

Identifier of the task to which the comment was added

MESSAGE_ID
integer

Identifier of the sent message in the task chat, returned when the new task card is active from module version tasks 25.700.0

Field IS_ACCESSIBLE_BEFORE

Required parameters are marked with *

Name
type

Description

IS_ACCESSIBLE_BEFORE*
string

Possible values:

  • Y (Yes) — yes
  • N (No) — no
  • undefined — not defined or check was not performed

Field IS_ACCESSIBLE_AFTER

Required parameters are marked with *

Name
type

Description

IS_ACCESSIBLE_AFTER*
string

Possible values:

  • Y (Yes) — yes
  • N (No) — no
  • undefined — not defined or check was not performed

Code Examples

How to Use Examples in Documentation

try
        {
        	const response = await $b24.callMethod(
        		'event.bind',
        		{
        			"event": "OnTaskCommentAdd",
        			"handler": "https://example.com/handler.php"
        		}
        	);
        	
        	const result = response.getData().result;
        	console.info(result);
        }
        catch( error )
        {
        	console.error(error);
        }
        
try {
            $response = $b24Service
                ->core
                ->call(
                    'event.bind',
                    [
                        'event'   => 'OnTaskCommentAdd',
                        'handler' => 'https://example.com/handler.php',
                    ]
                );
        
            $result = $response
                ->getResponseData()
                ->getResult();
        
            echo 'Success: ' . print_r($result, true);
            // Your required data processing logic
            processData($result);
        
        } catch (Throwable $e) {
            error_log($e->getMessage());
            echo 'Error binding event: ' . $e->getMessage();
        }
        
BX24.callMethod(
            'event.bind',
            {
                "event": "OnTaskCommentAdd",
                "handler": "https://example.com/handler.php"
            },
            function(result) {
                if (result.error()) {
                    console.error(result.error());
                } else {
                    console.info(result.data());
                }
            }
        );
        
require_once('crest.php');
        
        $result = CRest::call(
            'event.bind',
            [
                'event' => 'OnTaskCommentAdd',
                'handler' => 'https://example.com/handler.php'
            ]
        );
        
        echo '<PRE>';
        print_r($result);
        echo '</PRE>';
        

Continue Learning