[How to] How to save chats and speaker stats?

Want to save chats and speaker stats about each meeting on your self hosted instance? This post will give you a direction to get started with.

  • Jitsi developers have provided great architecture.

  • One of the prime components is Prosody which has some plugins like “mod_muc_lobby_rooms”, “mod_speakerstats_component” that can be used to add some more functional parts to Jitsi.

  • Remember that these plugins are written in Lua language. So if you are already a lua developer, good for you, but if you are new to Lua(like me) still not a problem.

Saving speaker stats -

  • The plugin required in this case is “mod_speakerstats_component.lua”. Make sure you are using it in prosody. It would be similar to enabling lobby which has been posted by my friend @corby in this article

  • Once you are done with prosody config changes, you can start making changes in the “mod_speakerstats_component.lua” file. There is a function named “room_destroyed()” in the file which is an event handler function which listens to “muc-room-destroyed” event.

  • The event passed to the ‘room_destroyed()’ function contains information regarding meeting including speaker stats. You can console the parameter using module:log("info", "Meetings info", event) which can be seen is prosody logs. :point_right: NOTE: Use json.encode(event) to see the contents in the variable.

  • Depending on the application, you can further save the file or make an API call using curl to save the parameter.

Saving meeting chats -

  • It is very similar to the previous part, the only change is the event listener. For chat, you will have to listen to
    muc_module:hook("muc-broadcast-message", handleBroadcastMessage,-1);
    where, handleBroadcastMessage is a function that you need to declare in the same Lua file(“mod_speakerstats_component.lua”).

  • This event listener needs to be added in process_host() function present in the same file.

  • Wherever a chat message is entered in the meeting, this event listens to the chat and using the event variable we can print the chat message which can be seen is prosody logs.

  • Formatting and extracting the required part of the JSON variable is up to you.

  • Later you can add the required things in a global variable and use this variable in the room_destroyed() function and save the variable in the required way.

This whole process can be done in a fresh prosody-plugin Lua file as well but I am not that confident with Lua which is why I chose this approach.

Restart the prosody service and you are good to go :smiley:


Do you have any reference files for this

See this if helps ( I am still working on private chat, looking for a way to get To name):

@kkd, Great, We managed to send the chats and speaker stats to other node server using OS curl calls for linux. Good to see a similar way of saving it into a file.

Did you managed to save private chats also.
I am having one issue about it, let me know if you have any pointers:

I could not get private chats through the hook that I used. I guess you need to search for the hook string that you can listen to. Not sure