Participant Count in Jitsi room



Is it possible to add participant count in Jitsi room? If possible, how can I add? Please help

How to get call duration after each call?

I think, on the client side, you can find members count using the following line :



For server side infos you can look at this

By adding this module you can request to prosody the participant’s count for a room


I added the following functions in mod_muc_size.lua to get real-time conferences and participants count on the server side.

PS : The code is not very optimised but it could be useful

function tablelength(T)
        local hash = {}
        local res = {}

        for _,v in ipairs(T) do
           if (not hash[v]) then
               res[#res+1] = v
               hash[v] = true

        local count = 0
        for _ in pairs(res) do count = count + 1 end
        return count

function getNbConfPart() 
    local tab={};

    --conferences count (without eliminating duplicates )
    for key, value in pairs(prosody.full_sessions) do
            if tostring(value["username"]:lower()) ~= "focus" then

    local nbPart = 0
    if it.count(it.keys(prosody.full_sessions))-1 >= 0 --participants count
            then nbPart= it.count(it.keys(prosody.full_sessions))-1

    local nbConf = tablelength(tab) --conferences count
    if nbPart == 0
            then nbConf=0

     --create result as json
    local result_json=array();
                    part= nbPart,
                    conf=tablelength(tab) -- eliminates count number of rooms

    -- create json response 
    return json.encode(result_json);

function module.load()
	module:provides("http", {
		default_path = "/";
		route = {
			["GET room-size"] = function (event) return wrap_async_run(event,handle_get_room_size) end;
			["GET sessions"] = function () return tostring(it.count(it.keys(prosody.full_sessions))); end;
			["GET room"] = function (event) return wrap_async_run(event,handle_get_room) end;
            ["GET nbConfPart"] = function (event) return wrap_async_run(event,getNbConfPart) end;

you get the result by sending an http request to “http://localhost:PROSODY_PORT/nbConfPart”
note that you must enable mod_muc_size module in prosody localhost virtualhost configuration file.


i’m still using prosody 0.9.X. This code also returns usernames, roles, jids, jitsi video muted, audio muted

function handle_get_room (event)
	local params = parse(event.request.url.query);
	local room_name = params["room"];
	local domain_name = params["domain"];
	local room_address = room_name .. "@" .. "conference." .. domain_name;
	local room = get_room_from_jid(room_address);
	local participant_count = 0;
	local occupants_json = array();

	log("debug", "Querying room %s", tostring(room_address));

	if room then
		local occupants = room._occupants;
		if occupants then
			participant_count = 0;
			for jid, occupant in pairs(occupants) do
				participant_count = participant_count + 1;
				-- filter focus as we keep it as hidden participant
				if string.sub(jid,-string.len("/focus"))~="/focus" then
					for jid2, pres in pairs(occupant.sessions) do
						local nick = pres:get_child_text("nick", "") or "";
						-- local email = pres:get_child_text("email") or "";
						local role = occupant.role or "";
						local videomuted = pres:get_child_text("videomuted", "") or "";
						local audiomuted = pres:get_child_text("audiomuted", "") or "";
							jid = tostring(jid),
							-- email = tostring(email),
							displayname = tostring(nick),
							role = tostring(role),
							videomuted = tostring(videomuted),
							audiomuted = tostring(audiomuted)
		log("debug", "there are %s occupants in room", tostring(participant_count));
		log("debug", "no such room exists");

	if participant_count > 1 then
		participant_count = participant_count - 1;

	local GET_response = {
		headers = {
			content_type = "application/json";
		body = json.encode(occupants_json);
	return GET_response;


Hello @Arthur_TOUMASSIAN

I don’t know if you could help but I have difficulties in finding the prosody module that manages events such as room and participants creation, etc. For example when a user joins a room, I want to store his JID, room name and more other information in an external database. do you have any tips for that ?


Hi @hkhait

I have the same needs.
This module may inspire you. Its hooks events you need. You just have to adapt handlers to do http requests to your stats api or directly write to DB. But as it needs prosody >= 0.10 i didn’t go further.
Please keep me informed if you manage to get something


Hello @Arthur_TOUMASSIAN,

Thanks for the link.
I tried to adapt handlers to get the needed information from events object but only resource-bind and resource-unbind handlers work. the other ones, such as muc-occupant-joined and muc-occupant-left (that are the most important events in this case) don’t do anything. Do you have any idea why ?

I found the following documentation about Prosody Events, it seems that the only supported events by default are resource-bind and resource-unbind.


Which version of prosody do you have? And mod_muc ? I was in the same case that you, i concluded that with my version of Prosody those events are not implemented.


I have the same version of prosody as which is Prosody trunk nightly build 747 (2017-02-19, 428d4abee723) and the mod_muc that comes with (attached below)

mod_muc.lua.txt (11.1 KB)


I’m looking at the code of prosody trunk here
I can find lines where events are fired
… so theorically should be fired

Maybe its the way it listens the event : global events, module events …
I didn’t try yet, my last resort will be to patch muc.lib.lua to inject my code directly in it. I know… a very poor solution :stuck_out_tongue:


This was the first thing that came to my mind too. Anyway, I’ll do my best and let you know :wink:


Which version of prosody are you using? For sure those are available in prosody-trunk as we use that version, but I’m not sure about 0.10…


I use Prosody trunk nightly build 747 (2017-02-19, 428d4abee723)
isn’t it outdated ?


Yep, we use the same. Hum, I’m sure those were available, I will double check when I get to the PC.


Ok, Thank you for your assistance.

I found the two events muc-occupant-left and muc-occupant-joined in /usr/lib/prosody/modules/muc/muc.lib.lua

I’m not Lua/Prosody expert but I tried to add the module below and it didn’t work :

-- jitsi-meet stats test
-- Author : Hamza KHAIT

local json = require "util.json";
local http = require "net.http";
local muc_size_url="http://localhost:5280/room";

-- Track users as they bind
module:hook("resource-bind", function(event)
	log("info", "TEST resource-bind");

-- Track users as they unbind
module:hook("resource-unbind", function(event)
	log("info", "TEST resource-unbind");

-- Track MUC occupants as they join/leave
module:hook("muc-occupant-joined", function(event)
	log("info", "muc-occupant-joined");

module:hook("muc-occupant-left", function(event)
	log("info", "muc-occupant-left");

when I join a room prosody log only displays “TEST resource-bind” and “TEST resource-unbind”
Something is missing ?


Yep, those events are there in trunk. So there must be something with your module … Are you loading the module globally or under the muc component.

Component "conference.yourdomain" "muc"
modules_enabled = { "jitsi-meet-stats-test" }


IT WORKS !! :smiley:

I was loading the module globally, that’s why muc events didn’t work.

Thank you very much @damencho