Documentation

web messenger

As the No.1 tool, Web messenger supplements traditional way of communication - telephone and email.

The Web Messenger interactive tool allows to effectively communicate and receive information directly via browser:

  • Bitrix24 account users are communicating via personal instant messages (just like in the online messengers);
  • List of contacts is formed according to the company structure;
  • Notification center displays data about new events in the account;
  • Presence of a user on the account (online) is indicated;
  • The users present on the account are engaged into "live" dialog;
  • Notifications about new messages appear on any account page;
  • Messages are delayed for the users who are not working at the present moment on the account;
  • Archive of user dialog messages is maintained;
  • User also can view personal correspondence from a profile of another user («Show messages»).

The use of Web Messenger negates the need of installing XMPP servers and special Jabber clients in a company. Web messenger is created with the support of all modern state-of-art browsers (HTML5, local storage and etc., are used).

Examples of use

To add messages to chat, the necessary chat ID must be known and method to send message to chat must be executed. To receive such ID, the /getChatId message must sent in the chat and to check the chat's number

Call the following API in the required code location:

if (CModule::IncludeModule('im'))
{
   $ar = Array(
      "TO_CHAT_ID" => 21441, // Chat ID
      "FROM_USER_ID" => 1, // ID of the user, who is the chat's participant
      "MESSAGE"     => "User message", // free text
   );
   CIMChat::AddMessage($ar);
}

Sent a system message:

if (CModule::IncludeModule('im'))
{
   $ar = Array(
      "TO_CHAT_ID" => 21441, // Chat ID
      "FROM_USER_ID" => 0, 
      "SYSTEM" => Y, 
      "MESSAGE"  => "System message", // Free text
   );
   CIMChat::AddMessage($ar);
}

Chat creation

<?php 
if (\Bitrix\Main\Loader::includeModule('im')) 
{ 
    $pic = $_SERVER['DOCUMENT_ROOT'] . '/test.jpg'; 
    $avatarId = \CFile::SaveFile(\CFile::MakeFileArray($pic), 'im'); 
    $chat = new \CIMChat; 
    $chat->Add(array( 
        'TITLE' => 'Test chat', 
        'DESCRIPTION' => 'Test chat description', 
        'COLOR' => 'RED',//color 
        'TYPE' => IM_MESSAGE_OPEN,//chat type 
        'AUTHOR_ID' => '1',//chat owner 
        'AVATAR_ID' => $avatarId,//chat avatar 
        'USERS' => false,
    )); 
}
//TYPE = IM_MESSAGE_CHAT – closed chat
//list of available colors: \Bitrix\Im\Color::getSafeColors()

Invitation to chat

<?php 
//invitation to chat
if (\Bitrix\Main\Loader::includeModule('im'))  { 
    $chat = new \CIMChat; 
    $chat->AddUser($chatId, $userId, $hideHistory = null, $skipMessage = false); 
//userId - can be a user array; 
//hideHistory - hide messages that were sent prior to entering the chat, true/false - this value is taken by default, 
//which is specified in the module settings. 
//skipMessage - skip the standard message about the chat participant invite. Specified as "false" by default. For example, to publish
// your own message.
}

//chat search by certain parameters
if (\Bitrix\Main\Loader::includeModule('im'))  { 
    $chat = new \CIMChat; 
    $res = \Bitrix\Im\chatTable::getList(array( 
        'filter' => array( 
            'TITLE' => '%red%' 
        ) 
    )); 
    if ($row = $res->fetch()) 
    { 
    } 
}

Write to chat

<?php 
if (\Bitrix\Main\Loader::includeModule('im'))  { 
    \CIMChat::AddMessage(array( 
        'FROM_USER_ID' => 1,  //author id
        'TO_CHAT_ID' => 19,  //chat id
        'MESSAGE' => 'Write to chat #19' 
    )); }
if (\Bitrix\Main\Loader::includeModule('im'))  { 
    \CIMChat::AddSystemMessage(array( 
        'FROM_USER_ID' => 1,  //author id
        'CHAT_ID' => 19,  //chat id
        'MESSAGE' => 'Sending system notification' 
    )); 
} 

Wrote to chat personally

<?php 
if (\Bitrix\Main\Loader::includeModule('im'))  
{  
    \CIMMessage::Add(array(  
        'FROM_USER_ID' => 1,  
        'TO_USER_ID' => 21, 
        'MESSAGE' => 'Sending to you into chat', 
    ));  
}


© «Bitrix24», 2001-2024
Up