Create short URLs without leaving Slack!
This project requires Node.js version 6.0.0 or higher. In order to install this integration in your Slack organization you will need to create a custom Slack app and activate a new "slash command". You will also need to have a Rebrandly account and a valid apikey. It should be simple enough to have them, but a dedicated tutorial will be published in the following weeks.
Run the slash command server on Heroku
1. Clone this repository:
git clone https://github.com/lmammino/slack-shorturl-integration.git
2. Create a new Heroku app:
cd slack-shorturl-integration heroku create slack-shorturl-integration
Beware that you might need to replace
slack-shorturl-integration with a unique name for an Heroku app (I might have taken this one
3. Configure the app:
heroku config:set --app slack-shorturl-integration SLACK_TOKEN=<YOUR_SLACK_TOKEN> REBRANDLY_APIKEY=<YOUR_REBRANDLY_APIKEY>
Be sure to replace
<YOUR_REBRANDLY_APIKEY> with your actual configuration values
4. Deploy the app:
git fetch --all git push heroku master
This will produce a long output. At the end of it you should see the URL of the app on Heroku. Copy it and paste it as Request URL in the slash command config on your Slack app.
Now your server should be up and running on Heroku. Enjoy it!
Run the slash command locally (or in a VPS)
1. Clone this repository and install the dependencies:
git clone https://github.com/lmammino/slack-shorturl-integration.git cd slack-shorturl-integration npm i
2. Configure the app
The app will need to have some environment variable properly set.
To do so, you can copy the file
.env and edit it to provide the correct values for
REBRANDLY_APIKEY. You can also specify
PORT to run the web server in a port of your own choice (by default
Alternatively you can simply export these variables in your current shell.
3. Start the server
npm run start:local
or, if you already have the configuration environment variable exported in the current session, you can simply run:
4. Get a public url with Ngrok
The server will now be available in
localhost. In order for Slack to reach it you will need a publicly available URL.
If you are in a development machine, you can easily get a temporary one using ngrok by running:
ngrok http 80
80 with the number of your port if you are using a custom one.
This command will print a public https URL. You can copy this into your Slack slash command Request URL.
That's it! :)
Bugs and improvements
The Making of
This code was actually written as part of a complete tutorial published on Scotch.io. This tutorial explains how to build your own custom Slack slash command using Node.js and Express. That's the reason why I tried to keep the code super simple and avoid additional complexity such as Babel and ES201X.
Licensed under MIT License. © Luciano Mammino.