   (if (= (:object data) "page")
     (doseq [pageEntry (:entry data)]
       (doseq [messagingEvent (:messaging pageEntry)]
-        (cond (contains? messagingEvent :message) (sendTextMessage (onMessage messagingEvent))
+        ; Check for text or attachments here
+        (cond (contains? messagingEvent :message) (onMessage messagingEvent)
           :else (println (str "Webhook received unknown messagingEvent: " messagingEvent)))))))

  (:gen-class)
  (:require [org.httpkit.client :as http]
            [clojure.pprint :as pprint]
            [clojure.data.json :as json]))

(defn webhook-is-valid? [request]
  (def params (:params request))

    (println messageData)
    (sendAPI messageData))

(defn sendImageMessage [[recipientId imageUrl]]
    (def messageData {:recipient {:id recipientId} :message {:attachment {:type "image" :payload {:url imageUrl}}}})
    (println messageData)
    (sendAPI messageData))

(defn onMessage [event]
  (let [senderID (get-in event [:sender :id]) recipientID (get-in event [:recipient :id]) timeOfMessage (get-in event [:timestamp]) message (get-in event [:message])]
    (println (str "Received message for user " senderID " and page " recipientID " at " timeOfMessage " with message:"))
    (println message)
    (println (:text message))
    ; Add rules here
    (cond
      (s/includes? (s/lower-case (:text message)) "help") (sendTextMessage [senderID "Hi there, happy to help :)"])
      (s/includes? (s/lower-case (:text message)) "image") (sendImageMessage [senderID "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/M101_hires_STScI-PRC2006-10a.jpg/1280px-M101_hires_STScI-PRC2006-10a.jpg"])
      :else (sendTextMessage [senderID (:text message)]))))

(defn route-request [request]
  (def data (get-in request [:params]))
