Adding Admin Functionality for Group Video Call Apps in React JS and Agora
Tags: react, webdev, webrtc, opensource
Published: 2021-10-25 18:40:30

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ojgp34ky5bmqip1rx2mt.png)
Integrating admin features in your video calling application can be very tedious and time-consuming. Maintaining a back end integrated with the video calling service for facilitating admin functions can be painful to create and maintain.

The Agora RTC and RTM SDKs allow you to add admin functions to your video calling application in minutes.

It can be hard to integrate the SDKs with the intricacies of React and leverage the capabilities of React. In this tutorial, we will write a bare-bones React application for adding admin functions to a basic video calling application. Agora provides a [React wrapper](https://github.com/AgoraIO-Community/agora-rtc-react) for the SDK, which will be used to create the basic video calling app.

You can test a live demo of the completed app [here](https://agora-admin.netlify.app/) and find the GitHub repository [here](https://github.com/prakhar0912/agora-video-calling-with-admin-controls).

##Prerequisites

*   An Agora developer account (see [How to Get Started with Agora](https://sso.agora.io/en/signup?utm_source=medium&utm_medium=blog&utm_campaign=adding-admin-functionality-for-group-video-call-apps-in-react-js-and-agora))
*   The basics of React
*   [Agora RTM SDK](https://docs.agora.io/en/Real-time-Messaging/product_rtm?platform=Web)
*   [Agora React Wrapper](https://github.com/AgoraIO-Community/agora-rtc-react)

##Signing Up with Agora

In order to use the Agora SDK, we need an App ID. To find out how to get one, click [here](https://docs.agora.io/en/Agora%20Platform/token?platform=Web).

_Note:_ This guide does not implement token authentication, which is recommended for all RTE apps running in production environments. For more information about token-based authentication in the Agora platform, see [https://docs.agora.io/en/Video/token?platform=All%20Platforms.](https://docs.agora.io/en/Video/token?platform=All%20Platforms)

##Getting Started with the Code

Start by creating a default React app using:

```
npx create-react-app agora-gc
```

And then open the folder in your preferred code editor. Install the Agora React Wrapper using:

```
npm install git://github.com/AgoraIO-Community/agora-rtc-react#v1.0.1
```

And then install the RTM SDK using:

```
npm install agora-rtm-sdk
```

We will be focusing on the admin functions aspect of the application.

##Application Architecture

We’ll create the standard Agora RTC client and add the corresponding event listeners. We’ll also initialize the RTM client with the user name and join the same channel as the RTC client. Agora provides channel attributes, and here we will use them to store the information of users in the video call, which is required for admin functionality and to send messages via RTM. The user who chooses to be an admin gets access to functions that send messages to users in the call via the RTM messaging to mute audio/video or kick them off the call.

##Application Explanation

###Data Storage:
{% gist https://gist.github.com/prakhar0912/6d27c57ca663d93f2ccf80c3a274be97 %}
###User data structure:
{% gist https://gist.github.com/prakhar0912/829df97e0193cc51bc27e3e27629f725 %}
###App Component
{% gist https://gist.github.com/prakhar0912/c5ad3084b5e79438dd3da5933f9fd3db %}

This is the parent function to a Form component and a Videos component. It contains an init function that initializes the RTM and RTC client, joins a channel, broadcasts the local audio and video tracks to the joined channel, and creates the necessary event listeners. On joining the RTM channel, the channel attributes are updated with the user’s information:

**RTC Event Listeners:**

Event listeners for when people join or leave the RTC video call:
{% gist https://gist.github.com/prakhar0912/761995dfb0bb54ae19eebcc769e9a435 %}
###An action function

Used for muting audio/video or leaving the video call:
{% gist https://gist.github.com/prakhar0912/489ec20ad98e58621a6795880f646a87 %}
###RTM Event Listeners:

Event listeners for when people send messages through the RTM channel. This is used to enable admin functionality:
{% gist https://gist.github.com/prakhar0912/f4428d5dd1b79087f996774487e53266 %}


The app component contains the Video component and the InitForm component, with either of them being viewable depending on whether the user has started the video call:
{% gist https://gist.github.com/prakhar0912/2ab70f01e5b81ede07b9cc20e28c0bcc %}

###InitForm Component

A form that is initially shown that takes in user information (App ID, channel name, and user name) and calls the init function with the above data.

##Videos Component

Using the user’s state and iterating through each user to render the front end of each user’s video stream and their controls (mute audio/video, kick/leave):
{% gist https://gist.github.com/prakhar0912/21d05689993bab79c3f1407ec004fd2a %}

##Controls Component

This component allows controlling muting audio/video or quitting the call. If the user is an admin, they can mute audio/video of other users or kick them off the call. The front end consists of icons.

Important functions of this component:
{% gist https://gist.github.com/prakhar0912/cfc0639db03e510810aa3f36bd85e076 %}

##Conclusion

Shazam! You can conduct a successful video call with admin controls in your React application. You can extract components from the GitHub repo and directly implement them in your application.

For additional features, a good starting point is the official docs, which you can find [here](https://docs.agora.io/en/Video/landing-page?platform=Web).

The code base for this tutorial is available on [GitHub](https://github.com/prakhar0912/agora-video-calling-with-admin-controls).

If you have questions, feel free to join our [Slack](https://www.agora.io/en/join-slack/) channel!