Created
March 17, 2014 18:02
-
-
Save mikebroberts/9604828 to your computer and use it in GitHub Desktop.
Send a message to Slack incoming webhook in Clojure.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns slack | |
(:require [clj-http.client :as client] | |
[clojure.data.json :as json])) | |
(defn send-to-slack | |
"Sends a simple message to slack using an 'incoming webhook'. | |
url will be of form: https://myapp.slack.com/services/hooks/incoming-webhook?token=mytoken . | |
(Exact url you should use will appear on the slack integration page) | |
text will be any valid message. | |
This implementation could be expanded if you wanted to specify channel, username, etc. | |
For more information see: | |
https://my.slack.com/services/new/incoming-webhook . (You'll need a slack account | |
to see that)" | |
[url text] | |
(client/post url {:form-params {:payload (json/write-str {:text text})}})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment