How to Get Access to Member Messages

Hi everyone! I’m trying to figure out a way with code for an admin to be able to see chat messages between members. For example if a member is sending inappropriate messages to other members we need to be able to have access to their conversations or message history to take proper action. Does anyone know how to do this? Thanks!