Simple endpoint for inviting yourself to any Slack group. Built with Sinatra. Great for open & free groups.
Example: http://rubybrigade.my/slack_invite/
Simplest (and free-est) way is to deploy this on Heroku's free dynos.
git clone git@github.com:klxrb/slack-invite.git
cd slack-invite
Setup and configure Heroku Toolbelt if not already.
heroku apps:create
heroku config:set SLACK_CHANNEL=<your-slack-channel-name>
heroku config:set SLACK_TEAM_NAME=<your-slack-team-name>
heroku config:set SLACK_TEAM_AUTH_TOKEN=<your-slack-team-auth-token>
-
As Team Admin, go to the Slack Web API Documentation and click "Create Token" and it should generate a API Token. This is the value for
SLACK_TEAM_AUTH_TOKEN
. -
Then go to the channel.list API Tester. Select your Slack team for the
token
field, click on "Test Method".
You should see something like this in the response field :-
{
"ok": true,
"channels": [
{
"id": "THIS-IS-YOUR-CHANNEL-ID",
"name": "general",
"is_channel": true,
Choose the channel ID you want the members to be invited into by default. That's the value for SLACK_CHANNEL
.
SLACK_TEAM_NAME
is just name name of your Slack team, you can get this from your team URL (e.g.http://team-name.slack.com
)
Deploy the Heroku app
git push heroku master
Go to https://your-app-name.herokuapp.com/invite.json, you should see a JSON with invalid_email
error. You can try to invite by simply doing https://your-app-name.herokuapp.com/invite.json?email=invite-this-member@email.com.
The endpoint only handles JSON requests, so you might want to use some AJAX to handle your form submissions.
<form id="slack_invite">
Email: <input type="email" name="email_invite" id="email_invite" placeholder="please@invite.me">
<button id="submit_button" type="submit">Submit</button>
</form>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
$(function(){
$('#slack_invite').submit(function(){
$.ajax({
url: 'https://your-app-name.herokuapp.com/invite.json',
dataType: 'jsonp',
data: {
email: $('#email_invite').val()
},
success: function(data){
if(data.ok){
alert("You're Invited !!!");
}else{
alert("Something went wrong :(");
}
}
})
})
})
</script>
Put this code on your website and you're good to go :)
You can look at the RubyMY invite page for example http://rubybrigade.my/slack_invite/