Group chat function

Basic command for adding a user to a dialog:

 window.imbaApi.openDialog(2)

Where you can substitute the user id in hooks and then the correspondence with this user will open, the user id is the id of the user registered on your site. If you need to add a user to a chat group, then you can create and pup a button on the site, by clicking which the user will automatically join the conversation.

Group chat works like a room. There are three main commands for creating rooms and adding users to it:

1)

imbaApi.openRoom (id)

Opens a room, with an ID number passed as an input parameter to a function

2)

imbaApi.addToRoom ({users_ids: ['10'], room_id: '114'})

The room administrator (room creator) can add new users to it. Accepts an array with fields users_ids and room_id as input. If a non-admin adds, the user will not be added.

3)

imbaApi.newRoom (['21', '10'], 'New Room 2', 0)

The user creates a new room, to which 2 or more users are added beside him, which are specified in the first input parameter, as in the example, Room name is the second parameter, the 3rd by default is 0.

Code for adding a group to the contact list

It can be added to any page on the site. When the page with this code is loaded, the group of the authorized user will be added to the list of his dialogs.

   <script>
  window.imbaApi.load();
  window.imbaApi.on('ImbaChat.Auth.Success', () => {

    //unique name of group
    let pipe = "TG_341";

    //Title of group
    let title = "Title of group"

    window.imbaApi.addToRoom({
      pipe: pipe,
      title: title,
      is_public: 1,
      type: imbaApi.room_type.conference,
    })
  });
</script>

The example of group chat using:

There is new function of adding an authorized user to the chat room, which is described in the code. And also, if you hover over the avatar of a user who wrote a message in a group chat, his name will be displayed and a dialogue will open with him by clicking.

Another articles:

Posted in Documentation on Sep 10, 2020

Tags

1 comments