All Projects → pvzig → Slackkit

pvzig / Slackkit

Licence: mit
Build Slack apps, in Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Slackkit

Awesome Bots
The most awesome list about bots ⭐️🤖
Stars: ✭ 2,864 (+193.14%)
Mutual labels:  chatbots, slack
Zewo
Lightweight library for web server applications in Swift on macOS and Linux powered by coroutines.
Stars: ✭ 1,856 (+89.97%)
Mutual labels:  server-side-swift, slack
Stevenson
Stevenson is a Vapor framework designed to build integrations between Slack apps, GitHub, JIRA and CI services (CircleCI).
Stars: ✭ 57 (-94.17%)
Mutual labels:  slack, server-side-swift
Chatskills
Run and debug Alexa skills on the command-line. Create bots. Run them in Slack. Run them anywhere!
Stars: ✭ 171 (-82.5%)
Mutual labels:  chatbots, slack
Perfect-Authentication
OAuth2 Implementations with Facebook, Google, LinkedIn, Slack, SalesForce and GitHub providers.
Stars: ✭ 14 (-98.57%)
Mutual labels:  slack, server-side-swift
Custom Slack Css
A custom CSS for Slack App users
Stars: ✭ 14 (-98.57%)
Mutual labels:  slack
Mattermost Openshift
An OpenShift 3 application template for mattermost
Stars: ✭ 27 (-97.24%)
Mutual labels:  slack
Versionmonitor
Monitors different kinds of software projects for new releases
Stars: ✭ 9 (-99.08%)
Mutual labels:  slack
Slack Cli
Powerful Slack CLI via pure bash. Rich messaging, uploads, posts, piping, oh my!
Stars: ✭ 850 (-13%)
Mutual labels:  slack
Kitura
A Swift web framework and HTTP server.
Stars: ✭ 7,533 (+671.03%)
Mutual labels:  server-side-swift
Obed Bot
🍴 Obed Slack Bot, na požiadanie kontroluje aktuálnu ponuku denného menu reštaurácii. [only for slovak|czech users]
Stars: ✭ 32 (-96.72%)
Mutual labels:  slack
Team Time Zone
Distributed teams are awesome. Time zones are awful.
Stars: ✭ 21 (-97.85%)
Mutual labels:  slack
D3 Digest
SlackBot that watch channels looking for links and reactions, and generates digests based on those reactions
Stars: ✭ 15 (-98.46%)
Mutual labels:  slack
Fredy
❤️ Fredy - [F]ind [R]eal [E]states [D]amn Eas[y] - Let the robot do the work...
Stars: ✭ 29 (-97.03%)
Mutual labels:  slack
Wc2018 Slack Bot
World Cup 2018 Slack Bot
Stars: ✭ 11 (-98.87%)
Mutual labels:  slack
Solarthing
Monitors an Outback MATE and a Renogy Rover - MPPT Charge Controller. Integrates with Grafana, PVOutput and more!
Stars: ✭ 33 (-96.62%)
Mutual labels:  slack
Slack Client
Slack Real Time Messaging API Client
Stars: ✭ 9 (-99.08%)
Mutual labels:  slack
Hubot Slack Docker
Docker container running Github Hubot.
Stars: ✭ 21 (-97.85%)
Mutual labels:  slack
Url Encoded Form
📝 Parse and serialize url-encoded form data with Codable support.
Stars: ✭ 32 (-96.72%)
Mutual labels:  server-side-swift
Vaporuploads
Demonstrating uploads in Vapor 4. Particularly large streaming uploads.
Stars: ✭ 19 (-98.06%)
Mutual labels:  server-side-swift

SlackKit

Build Status

Swift Version Plaforms License MIT SwiftPM compatible Carthage compatible CocoaPods compatible

SlackKit: Slack Apps in Swift

Description

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.

Installation

Swift Package Manager

Add SlackKit to your Package.swift

let package = Package(
	dependencies: [
		.package(url: "https://github.com/pvzig/SlackKit.git", .upToNextMinor(from: "4.6.0"))
	]
)

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

You can install it with homebrew: brew install libressl

For additional details, see the SKRTMAPI readme.

Carthage

Add SlackKit to your Cartfile:

github "pvzig/SlackKit"

SlackKit is now using .xcframeworks. When building your dependencies with carthage, please specify a platform: carthage bootstrap --use-xcframeworks --platform macos

CocoaPods

Add SlackKit to your Podfile:

pod 'SlackKit'

Usage

To use the library in your project import it:

import SlackKit

The Basics

Create a bot user with an API token:

import SlackKit

let bot = SlackKit()
bot.addRTMBotWithAPIToken("xoxb-SLACK-BOT-TOKEN")
// Register for event notifications
bot.notificationForEvent(.message) { (event, _) in
	// Your bot logic here
	print(event.message)
}

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.addWebAPIAccessWithToken("xoxb-SLACK-BOT-TOKEN")
bot.webAPI?.authenticationTest(success: { (success) in
	print(success)
}, 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)

OAuth

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.

Advanced Usage

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

Framework Description
SKClient Write your own client implementation
SKRTMAPI Connect to the Slack RTM API
SKServer Spin up a server for a Slack app
SKWebAPI Access the Slack Web API

Examples

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

Tutorials

Get In Touch

Twitter: @pvzig

Email: [email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].