Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Connect to the Slack Real Time Messaging API in Swift.


Swift Package Manager Add SlackKit as a dependency to your Package.swift and specify SKRTMAPI as a target dependency:
import PackageDescription
let package = Package(
    name: "SampleApp",
    products: [
            name: "SampleApp",
            targets: ["SampleApp"]),
    dependencies: [
        .package(url: "", .upToNextMinor(from: "4.3.0")),
    targets: [
            name: "SampleApp",
            dependencies: ["SKRTMAPI"])

When built using Swift Package Manager, SKRTMAPI includes the vapor websocket framework by default which requires libressl.

You can install it with homebrew: brew install libressl

If you'd like to use SPM without vapor websocket, you can modify the Package.swift file to exclude it:

let SKRTMAPI: Target = .target(name: "SKRTMAPI",
                               path: "SKRTMAPI/Sources",
                               exclude: ["Conformers/VaporEngineRTM.swift"])

#if os(macOS)
SKRTMAPI.dependencies = [
Carthage Add SlackKit to your Cartfile:
github "pvzig/SlackKit"

and run

carthage bootstrap

Drag the built SKRTMAPI.framework and it's dependencies SKCore.framework, SKWebAPI.framework, and Starscream.framework into your Xcode project.

CocoaPods Add SKRTMAPI to your Podfile:
pod 'SlackKit/SKRTMAPI'


To use the library in your project import it:

Carthage & SPM



import SlackKit

The Basics

Initialize an instance of SKRTMAPI with a Slack auth token:

let rtm = SKRTMAPI(token: "xoxb-SLACK_AUTH_TOKEN")

If your bot doesn't need any state information when you connect, pass false for the withInfo parameter:

let rtm = SKRTMAPI(token: "xoxb-SLACK_AUTH_TOKEN")
rtm.connect(withInfo: false)

Customize the connection with RTMOptions:

let options = RTMOptions(simpleLatest: false, noUnreads: false, mpimAware: true, pingInterval: 30, timeout: 300, reconnect: true)
let rtm = SKRTMAPI(token: "xoxb-SLACK_AUTH_TOKEN", options: options)

Provide your own web socket implementation by conforming to RTMWebSocket:

public protocol RTMWebSocket {
    var delegate: RTMDelegate? { get set }
    func connect(url: URL)
    func disconnect()
    func sendMessage(_ message: String) throws
let rtmWebSocket = YourRTMWebSocket()
let rtm = SKRTMAPI(token: "xoxb-SLACK_AUTH_TOKEN", rtm: rtmWebSocket)
You can’t perform that action at this time.