Skip to content

JuliaLangSlack/Slack.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slack

Check out the Docs

Current State

The only feature that still needs to be actively developed for the single production project utalizing this code is the addition of some functions for threaded messages. Once this is done, unless there is a community requested addition, this code will remain pretty much static.

Feel free to open an issue or Pull Request with additions or feature requests/bugs.

Setup

The first thing you will need to use this package is a Slack Workspace to install a Slack app into.

After that, you will need to add a webhook to your app such that you can send and retrieve data from the Slack Workspace.

Install

julia> ]
(v1.3) pkg> add Slack

Usage

Here is a simple example:

Note that the endpoint in the example and tests was deprecated automatically by Slack's API Security Crawler.

julia> using Slack

julia> endpoint = "/services/TQVJBU534/BR8C1LMPS/42thawJz34SWSgZCpniyLBSE"
"/services/TQVJBU534/BR8C1LMPS/42thawJz34SWSgZCpniyLBSE"

julia> data = "Hello World"
"Hello World"

julia> response = sendtoslack(data, endpoint)
"ok"

The result of running this code produces the following in the test Slack Workspace:

logo

To learn more about how data should be formatted before sending it as a argument to the above code, check out the Slack API Docs.

You can also check your messages format using Slacks Message Formatting Tool.

And here is a more complicated example using attachments:

julia> using Slack

julia> endpoint = "/services/TQVJBU534/BR8C1LMPS/42thawJz34SWSgZCpniyLBSE"
"/services/TQVJBU534/BR8C1LMPS/42thawJz34SWSgZCpniyLBSE"

julia> attachment = Dict("attachments" => [Dict("fallback" => "Required plain-text summary of the attachment",
                                               "color" => "#36a64f",
                                               "pretext" => "Optional text that appears above the attachment block",
                                               "author_name" => "Bobby Tables",
                                               "author_link" => "http://flickr.com/bobby/",
                                               "author_icon" => "http://flickr.com/icons/bobby.jpg",
                                               "title" => "Slack API Documentation",
                                               "title_link" => "https://api.slack.com/",
                                               "text" => "Optional text that appears within the attachment",
                                               "fields" => [Dict("title" => "Priority",
                                                   "value" => "High",
                                                   "short" => false
                                                   )]
                                           )])
Dict{String,Array{Dict{String,Any},1}} with 1 entry:
  "attachments" => Dict{String,Any}[Dict("author_link"=>"http://flickr.com/bob"


julia> response = sendattachmenttoslack(attachment, endpoint)
"ok"

The result of running this code produces the following in the test Slack Workspace:

logo