Skip to content

Instantly share code, notes, and snippets.

@mikebroberts
Created March 17, 2014 18:02
Show Gist options
  • Save mikebroberts/9604828 to your computer and use it in GitHub Desktop.
Save mikebroberts/9604828 to your computer and use it in GitHub Desktop.
Send a message to Slack incoming webhook in Clojure.
(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