Slack User Management APIs Finally Here?

Not exactly. But I can show you the next best thing!

You may have seen some large communities that have Slack teams with thousands of users; but, do they add them manually? Maybe. Probably not.

Slack Invitations using Slackin don’t give you much practical control over who can and cannot join your Slack team.

Communities like Bootstrap and Atom use similar automated Slack invitation sites, like the one seen here. This is a small app called Slackin; it allows you to enter some details about your team and you can easily deploy it into a number of platforms like Heroku. All your users have to do is enter their email address and they’ll receive a slack invitation. It works pretty well; but, you don’t have much control over it. You can’t, in a practical manner, restrict access to it, for example.

What if you only want to give access only to users who signed up for your service or purchased your product? Slackin isn’t much help in this case but using a simple library, specifically written for a Rails app, you can programmatically invite users.

Insert this into your /lib directory of your Rails app and make sure you have the httparty gem installed. After that, using it is as simple as writing a couple lines of code anywhere in your app.

client = Slack::Admin.new(token: "xxxx-xxxxxxxxx-xxxx")
client.invite(email: "johndoe@gmail.com")

You can give users access only to specific channels; simply add the channels option. Keep in mind that Slack will require to upgrade to a paid plan.

client.invite(email: "johndoe@gmail.com", channels: "C1234,C5678")

To get your Slack Team’s token, go to https://api.slack.com/custom-integrations/legacy-tokens. Slack encourages that you develop integrations differently; but, for now this is the only option. As far as I can tell, Slack does plan to eventually make user management API endpoints in the future; but, it’s anyone’s guess as to when exactly that will be. You can check out their Platform Roadmap for updates.

To see more of Slack’s undocumented endpoints, go to https://github.com/ErikKalkoken/slackApiDoc.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.