Skip to content

Instantly share code, notes, and snippets.

@poppingtonic
Forked from mikebroberts/slack.clj
Created April 11, 2014 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poppingtonic/10435280 to your computer and use it in GitHub Desktop.
Save poppingtonic/10435280 to your computer and use it in GitHub Desktop.
(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