Skip to content

PerfectServers/SwiftSlack

Repository files navigation

SwiftSlack - A Launchpad for Slack

Perfect logo

Perfect logo Perfect logo Perfect logo Perfect logo

Swift 3.0 Platforms OS X | Linux License Apache Twitter Join the chat at https://gitter.im/PerfectlySoft/Perfect Slack Status GitHub version

This project started as a Swift 3 port of Slackin. It does not include the socket.io feature of Slackin as it's been built with the intent to be as lightweight as possible.

SwiftSlack / Slackin provides a landing page you can point users to fill in their emails and receive an invite (https://slack.yourdomain.com). It also provides an SVG "badge" that can be included in places like your GitHub projects at a URL like: https://slack.yourdomain.com/badge.svg

Note: The current UI, as well as some portions of this readme are taken from the fabulous Slackin project, which was the inspiration for this project.

Because there is no database backend required, it can be configured easily by renaming the ApplicationConfiguration.json.default.json file to ApplicationConfiguration.json, and updating the "token" and "name" values in the JSON:

{
	"token": "---",
	"name": "perfectswift"
}

This package builds with Swift Package Manager and is part of the Perfect project.

Obtaining Configuration Details

The "name" is the subdomain (first part) of your Slack URL. For example, to access the Perfect Slack channel, the URL is https://perfectswift.slack.com. In the "https://perfectswift.slack.com" case the "name" would be "perfectswift".

You can find or generate your API test token at api.slack.com/web – note that the user you use to generate the token must be an admin. You need to create a dedicated @slackin-inviter user (or similar), mark that user an admin, and use a test token from that dedicated admin user. Note that test tokens have actual permissions so you do not need to create an OAuth 2 app. Also check out the Slack docs on generating a test token.

Important: If you use Slackin in single-channel mode, you'll only be able to invite as many external accounts as paying members you have times 5. If you are not getting invite emails, this might be the reason. Workaround: sign up for a free org, and set up Slackin to point to it (all channels will be visible).

Deploying

By far the easiest way to deploy SwiftSlack is using Perfect Assistant (PA). Either import the project directly from the URL into PA, or clone/download from GitHub and import as an existing project into PA.

Once imported, deploy to AWS or Google App Engine using PA. Make sure you check that the ApplicationConfiguration.json has been correctly configured and uploaded with the deployment.

When you run locally on macOS, the default port is set to 8181. When run on Linux, the default port is 8103.

To change this, change the values in main.swift:

#if os(Linux)
	let	FileRoot = "/perfect-deployed/swiftslack/"
	let port = 8103
#else
	let FileRoot = ""
	let port = 8181
#endif

Note that the var "FileRoot" is also different between macOS and Linux. Change this to suit as needed.

Further Information

For more information on the Perfect project, please visit perfect.org.