There is a way to monitor all messages both from public and private channel and you don't need to bother with the RTM API.
Use the Events Api and subscribe your app to following event types:
When you subscribe you have two options. Team Event and Bot Events. You want to subscribe to Team Events to get everything and without having to join any channels. You can also subscribe to bot events, but then your bot will only get events for channels he is invited to.
If you don't need to monitor all channels I strongly recommend the second option to increase transparency for users and to avoid unnecessary traffic on your server. There also is a upper limit on how many events Slack will send you (max 5.000 per hour). So depending on the traffic on your Slack you might miss events if you subscribe to everything.
Note that this is the ultimate spy app that enables you to monitor all communication on your Slack team. Please use this feature responsibly and make sure you don't break any local laws. e.g. in some European countries it is illegal to monitor the communication of an employee without his/her knowledge.