     (when-not (= first-msg {"type" "hello"})
       (throw (ex-info "Unable to connect" first-msg)))
     (keep-alive conn)
-    (route-messages conn incoming-messages)
+
     conn))
 
 (defn connect [token]

                      (json/parse-string true))
        incoming-messages (async/chan)
        ws-conn (websocket-client (:url conn-data)
                                  incoming-messages)]
    (assoc conn-data
           :ws-conn ws-conn
           :incoming-messages incoming-messages)))

(defn find-user-dm-id [conn user]
  (let [user-id (some #(if (= (:name %) user)

                                       :channel (find-channel-id conn channel)
                                       :text msg})))

(defn find-username [conn user-id]
  (if-let [username (some #(if (= (:id %) user-id)
                             (:name %))
                          (:users conn))]
    username
    (throw (ex-info "No such user" {:user-id user-id}))))

(comment
  (def conn (connect slack-token))

  conn

  (send-to-user! conn "ivan" "Send me a message!")


  (async/thread
    (loop [msg (async/<!! (:incoming-messages conn))]
      (when msg
        (let [user-id (:user msg)
              _ (assert (not= (:user msg) (:id (:self conn))))
              username (find-username conn user-id)
              dm? (.startsWith (:channel msg) "D")]
          (if dm?
            (send-to-user! conn username (format "Hi %s! You said \"%s\"" username (:text msg))))
          (recur (async/<!! (:incoming-messages conn)))))))

  )

