I've used Mattermost in the past and found it worked quite well. I don't know if it has the same number of integrations Slack does, but as a chat-room/text-communication tool it works well enough. It's also open-source and self-hosted. Perhaps I don't understand enough about how Slack works, but it seems like a huge security risk to me to couple (potentially) sensitive content (chat, e-mails, etc) with a hosted service.
https://about.mattermost.com/