Swiftpack.co - Package - SlackKit/SlackKit


Swift Version Plaforms License MIT SwiftPM compatible Carthage compatible CocoaPods compatible

SlackKit: Slack Apps in Swift


SlackKit makes it easy to build Slack apps in Swift.

It's intended to expose all of the functionality of Slack's Real Time Messaging API as well as the web APIs that are accessible to bot users. SlackKit also supports Slack’s OAuth 2.0 flow including the Add to Slack and Sign in with Slack buttons, incoming webhooks, slash commands, and message buttons.


Swift Package Manager

Add SlackKit to your Package.swift

import PackageDescription
let package = Package(
	dependencies: [
		.package(url: "https://github.com/SlackKit/SlackKit.git", .upToNextMinor(from: "4.1.0"))


Add SlackKit to your Cartfile:

github "SlackKit/SlackKit"


Add SlackKit to your Podfile:

pod 'SlackKit'


The Basics

Create a bot user with an API token:

import SlackKit

let bot = SlackKit()
// Register for event notifications
bot.notificationForEvent(.message) { (event, _) in
	// Your bot logic here

or create a ready-to-launch Slack app with your application’s Client ID and Client Secret:

import SlackKit

let bot = SlackKit()
let oauthConfig = OAuthConfig(clientID: "CLIENT_ID", clientSecret: "CLIENT_SECRET")
bot.addServer(oauth: oauthConfig)

or just make calls to the Slack Web API:

import SlackKit

let bot = SlackKit()
bot.webAPI?.authenticationTest(success: { (success) in
}, failure: nil)

Slash Commands

After configuring your slash command in Slack (you can also provide slash commands as part of a Slack App), create a route, response middleware for that route, and add it to a responder:

let slackkit = SlackKit()
let middleware = ResponseMiddleware(token: "SLASH_COMMAND_TOKEN", response: SKResponse(text: "👋"))
let route = RequestRoute(path: "/hello", middleware: middleware)
let responder = SlackKitResponder(routes: [route])
slackkit.addServer(responder: responder)

When a user enters that slash command, it will hit your configured route and return the response you specified.

Message Buttons

Add message buttons to your responses for additional interactivity.

To send messages with actions, add them to an attachment and send them using the Web API:

let helloAction = Action(name: "hello", text: "🌎")
let attachment = Attachment(fallback: "Hello World", title: "Welcome to SlackKit", callbackID: "hello_world", actions: [helloAction])
slackkit.webAPI?.sendMessage(channel: "CXXXXXX", text: "", attachments: [attachment], success: nil, failure: nil)

To respond to message actions, add a RequestRoute with MessageActionMiddleware using your app’s verification token to your SlackKitResponder:

let response = ResponseMiddleware(token: "SLACK_APP_VERIFICATION_TOKEN", response: SKResponse(text: "Hello, world!"))
let actionRoute = MessageActionRoute(action: helloAction, middleware: response)
let actionMiddleware = MessageActionMiddleware(token: "SLACK_APP_VERIFICATION_TOKEN", routes:[actionRoute])
let actions = RequestRoute(path: "/actions", middleware: actionMiddleware)
let responder = SlackKitResponder(routes: [actions])
slackkit.addServer(responder: responder)


Slack has many different oauth scopes that can be combined in different ways. If your application does not request the proper OAuth scopes, your API calls will fail.

If you authenticate using OAuth and the Add to Slack or Sign in with Slack buttons this is handled for you.

For local development of things like OAuth, slash commands, and message buttons, you may want to use a tool like ngrok.

Web API Methods

SlackKit currently supports the a subset of the Slack Web APIs that are available to bot users:

| Web APIs | | ------------- | | api.test| | api.revoke| | auth.test| | channels.history| | channels.info| | channels.list| | channels.mark| | channels.setPurpose| | channels.setTopic| | chat.delete| | chat.meMessage| | chat.postMessage| | chat.update| | emoji.list| | files.comments.add| | files.comments.edit| | files.comments.delete| | files.delete| | files.info| | files.upload| | groups.close| | groups.history| | groups.info| | groups.list| | groups.mark| | groups.open| | groups.setPurpose| | groups.setTopic| | im.close| | im.history| | im.list| | im.mark| | im.open| | mpim.close| | mpim.history| | mpim.list| | mpim.mark| | mpim.open| | oauth.access| | pins.add| | pins.list| | pins.remove| | reactions.add| | reactions.get| | reactions.list| | reactions.remove| | rtm.start| | stars.add| | stars.remove| | team.info| | users.getPresence| | users.info| | users.list| | users.setActive| | users.setPresence|

Don’t need the whole banana? Want more control over the low-level implementation details? Use the extensible modules SlackKit is built on:

| Module | Slack Service | | ------------- |------------- | | SKClient | Write your own client implementation| | SKRTMAPI | Connect to the Slack RTM API| | SKServer | Spin up a server| | SKWebAPI | Access the Slack Web API|


You can find the source code for several example applications here.


Get In Touch

Twitter: @pvzig

Email: peter@launchsoft.co


Stars: 664
Help us keep the lights on



4.1.0 - Feb 19, 2018

  • Update to Swift 4
  • Multiple workspace support

4.0.1 - Jul 14, 2017

  • Keep Package.swift up to date by using majorVersion: 4

4.0.0 - Jun 4, 2017



SlackKit is now universal! This release supports linux, macOS, iOS, and tvOS in a unified codebase.


SlackKit is now modular! It has been split into a few components so that you only need to pull in exactly what you need. You can see them on the organization page.


SlackKit is now Extensible! Don't like the defaults? Bring your preferred web socket client or server along by conforming to SlackKitServer and RTMWebSocket. Write your own client implementation with SKClient.

3.1.12 - Apr 9, 2017

  • Swift 3.1 update

3.1.11 - Mar 19, 2017

  • NetworkingInterface compilation fixes
  • Dependency fixes