Skip to content

Instantly share code, notes, and snippets.

@v-kolesnikov
Forked from mikebroberts/slack.clj
Created March 10, 2016 14:05
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 v-kolesnikov/e0435572556560833225 to your computer and use it in GitHub Desktop.
Save v-kolesnikov/e0435572556560833225 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