Up

Group chat function

Group chat is a popular feature of many websites and applications. It allows users to communicate with multiple people in real-time, making it an essential tool for collaborative work or social interaction. In this article, we will explore how to create and add users to group chats using the ImbaChat API.

  • To add a user to a dialog, you can use the following command:
    window.imbaApi.openDialog(2)

    Here, the user ID is substituted in hooks, and the correspondence with that user will open. The user ID is the ID of the user registered on your site. If you want to add a user to a chat group, you can create and pup a button on the site, by clicking which the user will automatically join the conversation.

Creating a group chat is done using three main commands:

1)

imbaApi.openRoom (id)

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

2)

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

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

3)

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

The user creates a new room, to which two or more users are added beside him, which are specified in the first input parameter. Room name is the second parameter, and the third 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>

This code 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 their dialogs.

In the example below, we demonstrate how to create a group chat using the ImbaChat API. The code adds an authorized user to the chat room and displays the user's name when hovering over their avatar.

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:

4 comments
  • I also want to log in on this screen when the user logs in to my own CRM system, and I want to ensure that they correspond among themselves. If this is possible or I need to open a user through the portal for each of them. My goal is to let users communicate among themselves on the CRM system.
  • BobAustin 2 years ago
    All functions implemented. I will test it, it looks like an accessible explanation to the client, I give a thumbs up for the article and in principle for the development on wordpress group chat.
  • A valuable article on the group chat function! It provides insights into the benefits and implementation of group chats using ImbaChat. The article explains how to create and manage group chats, including features like member invitations, permissions, and message history. The step-by-step instructions and code examples make it easy to understand the process of implementing group chats. This resource is highly recommended for anyone looking to enhance their chat system with group chat
  • This article offers valuable insights into the group chat function provided by ImbaChat. It explores the advantages and provides practical guidance on implementing group chats in your chat system. The article covers various aspects such as creating and managing group chats, member invitations, permissions, and message history. The step-by-step instructions and code examples make it easy to follow along and understand the process. Overall, this resource is highly recommended