Skip to content

A quick and dirty serverless solution to invite users to your Slack org

License

Notifications You must be signed in to change notification settings

stefanjudis/serverless-slack-invite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

serverless-slack-invite

A single serverless function using the Serverless framework to handle slack invites via POST.

Features

  • a single HTTP POST endpoint to invite new users

Getting started

Install the serverless-cli.

$ npm i -g serverless

Set the config credentials. This will write a new AWS config file to ~/.aws/credentials.

$ serverless config credentials --provider aws --key key_123 --secret secret_123

Clone the repo and navigate into it.

$ git clone git@github.com:stefanjudis/serverless-slack-invite.git
$ cd serverless-slack-invite

Install dependencies.

$ npm install

Deploy the serverless function with an access token and your organization sub domain for slack. 🎉

$ SLACK_TOKEN=slack_token SUB_DOMAIN=slack_subdomain serverless deploy

And you're done. The deployment will tell you where your new serverless endpoint will be located so that you can use it via Ajax.

Usage via JavaScript

Now that you have the endpoint running in the cloud you can write invite users via XHR.

// jQuery is available in this environment
$.post(
  '#{slack_invite_url}',
  { email: this.email.value }
).done( function( data ) {
  try {
    var response = JSON.parse(data.body)

    if ( response.ok ) {
      showSuccess();
    } else {
      showError( response.error );
    }
  } catch( error ) {
    showError();
  }
}).fail( function() {
  showError();
})

About

A quick and dirty serverless solution to invite users to your Slack org

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published