'Kick participant that joins a call

I am using iframe API of Jitsi, I would like to keep the limit of a room to only 3 participants. If a fourth participant joins the room, the participant should automatically get kicked. This is my current api, how do I kick the 4th participant?

var api = new JitsiMeetExternalAPI(domain, options);

            api.addListener('videoConferenceJoined', ({id}) => {
                let numberOfParticipants = api.getNumberOfParticipants();
                if(numberOfParticipants > 3) {
                     api.executeCommand('kickParticipant',
                     //
                   );
               }
            });


Solution 1:[1]

You can use the "participantJoined" event instead of "videoConferenceJoined".

As it is fired whenever a participant joins. While "videoConferenceJoined" fires when you join the conference.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MaXo