Sure but like, run Mattermost or Lync or an XMPP server with apps pre-built for it... don't build your own system. Just a waste of effort.
Compare with a small development team for a significant percentage of their time to build a halfway decent chat tool.
Miles of difference.