Heroku Slack



  1. Heroku Slack Free
  2. Slack Bot Heroku
  3. Heroku Slacker
  4. Heroku Slack Login
  5. Heroku Slack Download

See what developers are saying about how they use Slack. Check out popular companies that use Slack and some tools that integrate with Slack. Log in to your Heroku account from this secure Heroku login page.

GitHub Readme.md

Slack Invite Automation

A tiny web application to invite a user into your Slack team.

Inspired byHow I hacked Slack into a community platform with Typeformand Socket.io's Slack page.

This project supports Heroku, Azure, Cloud Foundry, Amazon Web Services (AWS), and ic.dev.

Settings

You can set variables for your own purpose in config.js or environment variables.

config.js

Fill out config.js as your infomation.

  • community: your community or team name to display on join page.
  • slackUrl : your slack team url (ex.: socketio.slack.com)
  • slacktoken : Your access token for Slack. (see Issue token)
  • inviteToken: An optional security measure - if it is set, then that token will be required to get invited.
  • recaptchaSiteKey: An optional security measure - if it is set, and recaptchaSecretKey is set, then a captcha will be required to get invited.
  • recaptchaSecretKey: An optional security measure - if it is set, and recaptchaSiteKey is set, then a captcha will be required to get invited.
  • locale: Application language (currently cs, de, en, es, fr, it, ja, ko, nl, pl, pt, pt-BR, tr, zh-CN and zh-TW available).
  • subpath: Sub-path in URL. For example, if /example is set, it's served in /example, not /. Default is /.

Environment Variables

You can set environment variables directly or in .env file.If you want to use a .env file, create a file in the root called .env with the following key/value pairs.(.env files are added to the .gitignore.)

  • COMMUNITY_NAME : Your community or team name to display on join page.
  • SLACK_URL : Your Slack team url (ex.: socketio.slack.com)
  • SLACK_TOKEN : Your access token for Slack. (see Issue token)
  • INVITE_TOKEN: An optional security measure - if it is set, then that token will be required to get invited.
  • RECAPTCHA_SITE: An optional security measure - used to enable reCAPTCHA.
  • RECAPTCHA_SECRET: An optional security measure - used to enable reCAPTCHA.
  • LOCALE: Application language (currently cs, de, en, es, fr, it, ja, ko, nl, pl, pt, pt-BR, tr, zh-CN and zh-TW available).
  • SUBPATH: Sub-path in URL. For example, if /example is set, it's served in /example, not /. Default is /.

Sample

You can test your token via curl:

Heroku / Azure

Add the application settings that are defined in the environment variables above.

Amazon Web Services (AWS)

If you have an AWS account and have already installed and configured the AWS CLI tool, you can easily deploy this application to API Gateway and Lambda via CloudFormation in a few minutes.

Instead of editing config.js, take these steps:

  1. Copy aws/config.example.sh to aws/config.sh
  2. Edit the values in aws/config.sh, which correspond to the variables described above, plus these:
    • StackName: the name of the CloudFormation stack to create
    • S3BucketArtifacts: the name of an existing S3 bucket you have write access to, for storing deployment artifacts
    • S3PrefixArtifacts: the prefix to use within that S3 bucket for all deployment artifacts written
  3. Run aws/deploy.sh to create the CloudFormation stack and deploy your application, outputting the URL
  4. (Optional) For a friendlier URL, log into the AWS web console and establish a custom domain pointing to the API Gateway stage deployed in step 3.

If you haven't already installed the IC CLI, please refer to the documentation.

Deploy the lsuss.slack_inviter brick directly from the IC Public Index:

Retreive the id and url of the API:

Run

Node.js is required.

You can access http://localhost:3000 on your web browser.

Run with Docker

It's easy to run this service if you have installed Docker on your system.Pull the Docker image from Docker Hub.

Or, You can build a Docker image yourself.

Issue token

You should generate the token in admin user, not owner. If you generate the token in owner user, a missing_scope error may occur.

There are two ways to issue the access token.

Legacy tokens

  1. Visit https://api.slack.com/custom-integrations/legacy-tokens.

  2. Click Create token.

Heroku Slack Free

OAuth tokens

  1. Visit https://api.slack.com/apps and Create New App.

  2. Click 'Permissions'.

  3. In 'OAuth & Permissions' page, select admin scope under 'Permission Scopes' menu and save changes.

  4. Click 'Install App to Workspace'.

  5. Visit https://slack.com/oauth/authorize?&client_id=CLIENT_ID&team=TEAM_ID&install_redirect=install-on-team&scope=admin+client in your browser and authorize your app.

    • This form requires the client permission. Otherwise, you can see {'ok':false,'error':'missing_scope','needed':'client','provided':'admin'} error.
    • Your TEAM_ID is the subdomain for your slack team, e.g. myteam.slack.com - your TEAM_ID is myteam.
    • Your CLIENT_ID found in 'Basic Information' section for your App.
    • You will be shown a Installed App Settings > OAuth Tokens for Your Team screen.
    • You can test auto invites with curl by providing the OAuth Access Token.

Badge

You can use the badge to show status of user in your slack.

  • With default colors:

  • With custom colors:

    • ?colorA=abcdef Set background of the left part (hex color only)
    • ?colorB=fedcba Set background of the right part (hex color only)

reCAPTCHA

Register a new site in Google reCAPTHCAas reCAPTCHA v2 type.

Set 'Site key' as recaptchaSiteKey or RECAPTCHA_SITE,and 'Secret key' as recaptchaSecretKey or RECAPTCHA_SECRET.

Associate fork with heroku

If you use the 'Deploy to Heroku' button and want to modify your App you shouldfork this project. After forking and making changes you should associate yourrepo with the deployed instance by running:

$ heroku git:remote -a thawing-inlet-61413 replacing your heroku app's nameand running

$ git push heroku master to upload the changes. For full details seeHeroku: deploying with git

Whether they're publishing notifications, responding to /slash commands or carrying a conversation, bots have become an integral part of the way we work with Slack. A bot can do any number of things for your team as part of your day-to-day work, you're only limited by your imagination. For some first-hand experience, check out the Heroku Button Gallery, where users have created all types of bots: from fun bots like poker and Jeopardy!, to more practical ones like a bot that tracks the satisfaction of your team members or one that reminds your team to review existing pull requests.

That said, the real power and fun of Slack bots comes once you know how to build your own. In this post, we'll show you how to create and deploy a Slack bot that will respond to /slash commands in order to show the top trending repos in GitHub. While a Slack bot can be built in practically any language, today we're going to build ours with Node, and not just because I 💖 Node. Anything beyond a simple notification bot depends on Slack's WebSocket-based RTM (Real Time Messaging) API, and WebSockets and Node go together like 🍔🍟.

We've got a lot of ground to cover, here's an outline of the journey we're about to take:

Getting Started

Let me introduce you to 🌟 Starbot, the example we'll be working with today. It's soon-to-be the easiest way to stay apprised of hip repos on GitHub, from the comfort of your favorite Slack channel.

Before you begin

Here's what you'll need:

  • A (free or better) Heroku account
  • The Heroku Toolbelt
  • A Slack team to abuse
  • Node (5.7.* preferably)
  • The burning desire to scream IT'S ALIVE.

This guide bounces between Slack, Heroku and your local development machine — so I've prefixed the sub-titles with the applicable logo where appropriate.

Create a custom Slack integration

We're going to make a custom integration bot designed explicitly for your team. As a bonus, I'll show you how to easily distribute your bot using the Heroku Button, so that you can share your creation with everyone – even grandma.

(Note that if you are building a serious bot, you will ultimately want to run it on Hobby rather than Free dynos to avoid any issues with dyno sleeping and idling. But Free dynos are great for building and testing.)

First, visit slack.com/apps/build and select 'Make a Custom Integration' as seen below.

Run Starbot locally

Starbot is essentially a bare-bones Express app, you can find detailed instructions on running it locally in the projectsREADME.md.

Clone the project

Install dependencies

Copy .env-example to .env

Start Starbot

That's it! Visit localhost:3000 and make sure Starbot is running.

Deploy Starbot to Heroku

We could push our code to Heroku without ever visiting the command line, but what fun would that be?

Create a Heroku app, with the Heroku Toolbelt

Push our code

Did we just deploy this application in two commands? Yes, yes we did! Heroku installed the dependencies in Starbot's package.json file automatically, and gave us a URL so that we can visit our newly deployed app.

Open the app in a browser

Now Starbot is running on Heroku, but it doesn't know anything about Slack, and Slack doesn't know anything about it. I expect they'll soon be fast friends, so let's make introductions.

Publish Notifications to Slack

Slack Bot Heroku

Heroku Slack

While publishing notifications to Slack is the simplest of custom integrations, it's still pretty darn cool, especially with a sprinkling of Heroku Add-ons. Let's show Starbot how to find trending GitHub projects and publish them to a Slack channel every morning. In this case, Starbot is using the BotKit framework from the folks at Howdy.ai.

Set up an 'Incoming WebHook' on Slack

Slack will provide us with the API endpoint, or webhook; later, we'll POST data to this endpoint. Select 'Incoming WebHooks' and choose a channel.

Again, the above selection can be found at {your-team}.slack.com/apps/build/custom-intergration

Now you're the proud new owner of a Slack 'Incoming WebHook'! The configuration page includes a lot of great information about formatting and delivering messages to your new webhook, but what we need first is the 'Webhook URL'. It should look something like this:https://hooks.slack.com/services/T0..LN/B0..VV1/br..dd

Found it? đź‘Ź Now let's move right along.

Publish a Notification to Slack from Heroku

Slack

Now that we've deployed our Starbot to Heroku and added an incoming webhook on Slack, it's time to connect the dots.

First, remember the webhook URL I had you save? Let's put it to work by setting a WEBHOOK_URLconfig var. This makes the value available to Starbot.

Heroku Add-ons allow us to quickly extend the functionality of our application, in this case, we're going to use the Scheduler add-on to deliver trending GitHub repos to Slack daily.

Heroku Slacker

We can provision the add-on from the dashboard, or from the CLI with the Heroku Toolbelt.

Then add a scheduled task, and configure it to run daily.

Our new scheduled task will create a one-off dyno and execute npm run notify, which is defined in this bit of our package.json.

We could wait patiently for the task we scheduled to fire—or we could just run our own one-off dyno, and trigger the notification ourselves. Immediate gratification, FTW.

Let the notifications commence.

Receive and Respond to /slash Commands

Slash commands are a personal favorite—enabling you to listen for a custom command, across channels, and triggering a POST or GET request to a configurable endpoint. In this case, that endpoint will be the Starbot application we deployed earlier, and responding to /slash commands will let our bot do a lot more than post once a day!

Creating a /starbot slash command

Return to the 'Build a Custom Integration' page and select 'Slash Commands'.

Next, pick a name, it must begin with /.

Heroku Slack Login

Now that we've created the command, we need to configure it. Starbot is expecting a POST request to arrive at /commands/starbot.

Slack has also provided us with a token specific to this command, something like: JzRR6hEuh3f749iXY3qEpVgN. We're going to use this to verify the payload Starbot receives is coming from Slack.

It wouldn't hurt to choose an appropriate name, icon, descriptive label and some autocomplete text—you could make something up, or use the suggestions provided in Starbot's readme.

Configuring the /starbot command on Heroku

We've already deployed Starbot to Heroku, so it's waiting patiently for POST requests from Slack, but at the moment Slack's requests are going to receive a 402 (Unauthorized) response. To fix that, we'll need to authenticate the bot with Slack, which is easy. We'll just use the Heroku Toolbelt to set a STARBOT_COMMAND_TOKENconfig var.

Your slash is my command

Connecting a Bot to the Slack RTM API

And finally the star of the show, a developer's best friend, the real-time bot. Fortunately, no matter how tricky your bot is to build, configuring and deploying it to Heroku is simple.

Connecting a bot to the Slack RTM API

Ok, one last trip to the 'Build a Custom Integration' page and this time we're going to select 'Bots'.

We get to give our bot a name!

And again, we're presented with the opportunity to customize the bot we've just created by giving it a name, description, icon, etc. You'll notice that the bot isn't currently following any channels. Bots are like vampires: they must be invited to a channel before they can follow it (any takers for BuffyBot?).

Take note of the API token, which is going to look like this: xoxb-253973540645-lAJG4hL34343f3pk52BE6JO. Without it, we won't be able to authenticate.

Configuring the bot on Heroku

The Starbot bot won't attempt to connect to Slack's RTM API without a token, so once more, let's use the Heroku Toolbelt to set a SLACK_TOKEN config var.

That's it! Head over to your Slack channel and use the /invitecommand to invite our @starbot bot to the channel. Then say hello to him, or her!

It's alive, it's alive, it's ALIVE!

Share Your Bot with the Heroku Button

The Slack Button makes it easy for other Slack users to add your bot to their team, but the Heroku Button makes it just as easy for other developers to deploy and manage your bot themselves.

Adding a button to your bot is as simple as creating an app.json file, and adding the button to our GitHub readme.

Heroku Slack Download

Creating an app.json

The app.json file is a manifest format for describing web apps. Here's the interesting bits from Starbot's app.json:

As you can see above, we begin by specifying our apps name, description and repo. We then declare the environment variables Starbot requires to run. Learn more about the app.json schema on the Dev Center.

Adding the Heroku Button to the repo

The last thing we must do before people can begin deploying Starbot with the Heroku Button, is to add it to the project's README.md:

Heroku will automatically infer the repository URL from the referrer header when someone clicks on the button.

Epilogue

Now that you’ve got the basics down, a whole new world of functionality is at your team’s fingertips. Not just your team’s either–with a little more work you can offer your bot as a service for others on Slack through the App Directory. Peruse the directory to see the many ways teams are extending Slack, whether it's with the outside world through Customer Support apps, or internally with HR or Office Management. To learn more about offering your app, check out their getting started guide.