Sending Messages to Slack with Slackdraft

Feb 22, 2015 Ruby


Slack is the finest messaging and chat platform to find itself entangled in the world wide web since the dot com boom. They have a free-tier, which allows for unlimited people, but integrations like Google Apps and webhooks are limited. Check them out at



Like any other gem:

gem install slackdraft


I created the gem to allow for really simple integration into Slack. Some of the features include:

See examples of pre-formated alerts in the examples/formatted/.

Ruby Usage

Using the gem is very simple. Here is an example:

require 'slackdraft'
url = "https://slack/webhook/url"
slack =
# Url of the icon or emoji
# slack.icon_url    = "https://..."
slack.icon_emoji  = ":fire:"
# Set the bot username
slack.username    = "SlackDraft"
# Set the channel     = "#general"
# Set text
# Or you can pass text in as an array
# slack.text        = ["Your message here!", ">_*And can have* formatting_"]
slack.text         = "Your message here! _*And can have* formatting_"

# Send the message
  #-> true/false

For more examples, see the examples/ directory.

Command-line Usage

Seriously, it’s just as simple. Instead of using curl, use this:

slackdraft -u mike \
    -c "#slackdraft" \
    -m "This is our *formammted message*" \

Note: The CLI version does not support Slack Attachments

Help text

$ slackdraft -h
Usage: slackdraft [options] url

Slack with less Kurt Russell


    -h, --help                       Show command line help
        --version                    Show help/version info
    -c, --channel CHANNEL            Channel to send message to
    -u, --username USER              User to send message as
    -m, --message MESSAGE            Message to send
    -e, --emoji EMOJI                Emoji to prefix message with
    -i, --icon ICON                  Icon to prefix message with

comments powered by Disqus