use XMPP or Matrix.
XMPP is mostly dead these days. The protocol is very inefficient (it's all XML) which isn't ideal on mobile devices since it uses more bandwidth to transfer and more processing power to parse.
I work at a big tech company, and at work we use Mattermost hosted outside our data center for cases where our internal stuff doesn't work. It seems fine and I think it's open-source, but I don't know a lot about it.
I've heard about Matrix but haven't tried it yet! Is it good?
What about IRC?