License: GPL-3.0

Language: Swift

Keywords: slack, swift, travis, vapor

Bob 👷

Bob is an extendable Slack bot written in Swift used to communicate with TravisCI and GitHub APIs. It's used to perform tasks of repetitive nature that cannot be fully automatized, such as creating release candidates for the App Store.

Simply send a message to Bob on Slack, and it will do the job for you.


Bob operates using commands. It comes with a couple of customizable commands, but new ones can easily be created. See creating custom commands for more information.

All commands are invoked by typing in {name} parameters.
For example:

build staging

could trigger a job on Travis that would create a build with staging configuration and distribute it to testers.
To see how a command should be used, type {name} usage


A dumy command that can be used to check if Bob is running. Simply say hello to Bob, and it will greet you back.


You can see which version of Bob is currently running by typing version

Travis Script

TravisScriptCommand is a configurable command that triggers a job on Travis and executes a script there. The command can have multiple targets that can be specified at runtime.
The script to run for each target is specified when the command is instantiated.
For example:

let buildTargets = [
    TravisTarget(name: "staging", script: Script("fastlane ios distribute_staging")),
    TravisTarget(name: "testflight", script: Script("fastlane ios distribute_testflight")),
let buildCommand = TravisScriptCommand(name: "build", config: travisConfig, targets: buildTargets, defaultBranch: "Develop")
try bob.register(buildCommand)

would register a command with the name build. Typing build staging would start the lane distribute_staging on Travis.

Align Version

iOS specific command used to change the CFBundleShortVersionString and CFBundleVersion values in specified .plist files.
For example:

let plistPaths: [String] = [
let alignCommand = AlignVersionCommand(gitHub: gitHub, defaultBranch: "Develop", plistPaths: plistPaths, author: author)
try bob.register(alignCommand)

would register a command that can be invoked by typing align 3.0 4. Bob would then create a commit on GitHub by changing the 3 specified files.

Bump build number

iOS specific command used to increase the CFBundleVersion values in specified .plist files. Increases the build number by 1, if it is numeric.
For example:

let plistPaths: [String] = [
let bumpCommand = BumpCommand(gitHub: gitHub, defaultBranch: "Develop", plistPaths: plistPaths, author: author)
try bob.register(bumpCommand)

would register a command that can be invoked by typing bump. Bob would then create a commit on GitHub by changing the 3 specified files.

Getting started

Creating a bot on Slack

Bob requires a Slack token in order to work. You can obtain one by creating a slack bot:

  1. Open the custom integration page
  2. Select Bots
  3. Type in a username for your bot. bobthebuilder works out nicely
  4. Copy the API Token field. Bob will use this to connect to slack

Starting it up

Bob can be set up just as any other Swift Package, but since it relies on Vapor💧 we recommend setting it up with the Vapor toolbox. To install vapor toolbox you can follow the manual

Once you have the toolbox setup, you can start by creating a new project:

vapor new BobTheBuilder
cd BobTheBuilder

After the template is cloned, change the Package.swift file to:

import PackageDescription

let package = Package(
    name: "BobTheBuilder",
    dependencies: [
        .Package(url: "https://github.com/N26-OpenSource/bob.git", majorVersion: 0)

You can delete the unused template files by running:

rm -rf Sources/App/Controllers
rm -rf Sources/App/Models

All of your custom code will reside in the Sources/App folder.
Create an Xcode project by running

vapor xcode

Change the Sources/App/main.swift file to:

import Bob

let config = Bob.Configuration(slackToken: "your-slack-token")
let bob = Bob(config: config)

try bob.start()

and you're good to go. Select the App scheme and run it. You can now send messages to Bob via Slack, and it will respond.

Using the TravisCI API

In order to use commands that communicate with the TravisCI API, you will need to provide a configuration. The configuration consists of

  • Url of the repo on Travis. Along the lines of https://api.travis-ci.com/repo/{owner%2Frepo}
  • Access token. You can obtain one by running gem install travis && travis login && travis token

Using the GitHub API

In order to use commands that communicate with the GitHub API, you will need to provide a configuration. The configuration consists of

  • Your GitHub username
  • A personal access token with read/write permissions. See this link on instructions how to generate one
  • Url of the repo on GitHub. Alogn the lines of https://api.github.com/repos/{owner}/{repo}

Command chaining

Bob supports sending multiple commands using 1 slack message. Just separate commands using | .
For example:

sync strings | align 3.0 5 | build staging | build testflight

could be used when creating a release candidate for the app store. It would update the strings on the repository, set the version and build the app for 2 environments

Creating custom commands

Custom commands can be created an provided to Bob. To create a command implement the Command protocol.

public protocol Command {
    /// The name used to idenitfy a command (`hello`, `version` etc.). Case insensitive
    var name: String { get }
    /// String describing how to use the command.
    var usage: String { get }
    /// Executes the command
    /// - Parameters:
    ///   - parameters: parameters passed to the command
    ///   - sender: object used to send feedback to the user
    /// - Throws: An error is thrown if something goes wrong while executing the command, usualy while parsing the parameters
    func execute(with parameters: [String], replyingTo sender: MessageSender) throws

The actual work happens in the execute method. All of the parameters the user typed in will be passed to the method as [String]. To inform the user about progress of the command, call the send method on the sender object. It will send the message to the user via Slack. If any errors occur during the execution, simply throw them.

Using existing APIs

Bob comes with a subset of TravisCI and GitHub APIs written in swift.


Only contains a method to execute a script exposed via the TravisScriptCommand


Contains low level methods for manipulating files and trees on GitHub. For the complete set of methods, check GitHub.swift

Project Statistics

Sourcerank 6
Repository Size 66.4 KB
Stars 37
Forks 6
Watchers 5
Open issues 1
Dependencies 1
Contributors 5
Tags 8
Last updated
Last pushed

Top Contributors See all

i-dama Patrick Balestra Daniel Peter Bernhard Eiling vincent audoire

Recent Tags See all

1.2.1 July 03, 2018
1.2.0 July 03, 2018
1.1.0 April 13, 2018
1.0.2 October 06, 2017
1.0.1 August 31, 2017
1.0.0 August 30, 2017
0.1.7 June 30, 2017
0.1.6 March 06, 2017

Something wrong with this page? Make a suggestion

Last synced: 2018-07-22 08:44:24 UTC

Login to resync this repository