OnBeforeSessionTransfer
Description and parameters
Event receives the object \Bitrix\Main\Event.
Input parameters can be retrieved via $eventParams = $event->getParameters();
Parameters
Parameter | Description |
---|---|
session | Array with session data, forwarded to a new agent. Current agent from which conversation is to be removed - indicated in OPERATOR_ID element. |
config | Information about Open Channel to which session belongs. |
chat | Object Bitrix\ImOpenLines\Chat from which such session chat data can be retrieved. |
reasonReturn |
Reason
List of available reasons:
Attention! Current list of reasons can be viewed in the class \Bitrix\ImOpenLines\Queue.
\Bitrix\ImOpenLines\Queue::REASON_DEFAULT; //default \Bitrix\ImOpenLines\Queue::REASON_OPERATOR_ABSENT = 'VACATION'; //vacation \Bitrix\ImOpenLines\Queue::REASON_OPERATOR_DAY_PAUSE = 'NONWORKING'; //non-working time \Bitrix\ImOpenLines\Queue::REASON_OPERATOR_DAY_END = 'NONWORKING'; //non-working time \Bitrix\ImOpenLines\Queue::REASON_OPERATOR_DELETED = 'DISMISSAL'; //agent dismissed \Bitrix\ImOpenLines\Queue::REASON_REMOVED_FROM_QUEUE = 'REMOVING'; //agent deleted \Bitrix\ImOpenLines\Queue::REASON_OPERATOR_NOT_AVAILABLE = 'NOT_AVAILABLE'; //agent is unavailable \Bitrix\ImOpenLines\Queue::REASON_OPERATOR_OFFLINE = 'OFFLINE'; //agent is offline \Bitrix\ImOpenLines\Queue::REASON_QUEUE_TYPE_CHANGED = 'DEFAULT'; //default for assigning new agent. |
newOperatorQueue | Array. The most important parameter to be returned in the event. When required, array elements can be updated and sorting logic modified.
Array elements:
|
Data verification
Data returned by the handler is verified. When something does not pass the verification, standard algorithm is triggered that removes the handler from equation.
Creates additional event OnErrorEventBeforeSessionTransfer.
You can subscribe it for debugging. Passes in parameters the array of errors and the object, returned by event handler.
Result example
array ( 'errors' => array ( 0 => 'The result of the processing of the event returned with an error', ), 'eventResult' => Bitrix\Main\EventResult::__set_state(array( 'moduleId' => NULL, 'handler' => NULL, 'type' => 0, 'parameters' => array ( 'RESULT' => 5, ), )), )
This solution must significantly simplify debugging.
Code example
"Draft" events
$eventManager = \Bitrix\Main\EventManager::getInstance(); $eventManager->addEventHandler('imopenlines', 'OnBeforeSessionTransfer', 'onBeforeSessionTransfer'); $eventManager->addEventHandler('imopenlines', 'OnErrorEventBeforeSessionTransfer', 'onErrorEventBeforeSessionTransfer'); public static function onBeforeSessionTransfer(\Bitrix\Main\Event $event) { $eventParams = $event->getParameters(); //test define("LOG_FILENAME", $_SERVER["DOCUMENT_ROOT"]."/log.txt"); AddMessage2Log(var_export($eventParams,1), 'onBeforeSessionTransfer'); //END test $eventParams['newOperatorQueue'] = [ 'RESULT' => true, 'OPERATOR_ID' => 1, 'OPERATOR_LIST' => [], 'DATE_QUEUE' => false, 'QUEUE_HISTORY' => [ 1 => true, ], ]; return new \Bitrix\Main\EventResult( \Bitrix\Main\EventResult::SUCCESS, $eventParams ); } public static function onErrorEventBeforeSessionTransfer(\Bitrix\Main\Event $event) { $eventParams = $event->getParameters(); //test define("LOG_FILENAME", $_SERVER["DOCUMENT_ROOT"]."/log.txt"); AddMessage2Log(var_export($eventParams,1), 'OnErrorEventBeforeSessionTransfer'); //END test }
© «Bitrix24», 2001-2024