How to listen to slack messages using clojure?

Viewed 262

I am using clj-slack start method for getting the web-socket url and then passing it to the connect method of gniazdo for listening to the web-socket.

(require '[clj-slack.rtm :as slack])
(require '[gniazdo.core :as ws])

(def connection {:api-url "https://slack.com/api" :token "your token"})

(defn reset-conn [options]
(def socket
  (ws/connect
    (:url (slack/start options))
    :on-receive #(prn 'received %))))
(reset-conn connection)

This code is working fine but it only provides information about who is active or away for slack:

received"{\"type\":\"presence_change\",\"presence\":\"active\",\"user\":\"U7BCQHWHY\"}"

But I also want to listen to the messages.

I don't know why messages are not printed though it was stated in slack-api documentation that rtm(real time messaging) is for messaging session.

0 Answers
Related