{"id":16714456,"url":"https://github.com/jcorrado/slackbot-router","last_synced_at":"2026-04-27T18:32:17.890Z","repository":{"id":62433103,"uuid":"117398338","full_name":"jcorrado/slackbot-router","owner":"jcorrado","description":"A Clojure Slack bot request routing framework","archived":false,"fork":false,"pushed_at":"2018-01-25T20:00:56.000Z","size":16,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-19T05:42:53.979Z","etag":null,"topics":["clojure","library","slack"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcorrado.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-14T03:25:18.000Z","updated_at":"2018-08-09T10:27:58.000Z","dependencies_parsed_at":"2022-11-01T21:01:21.850Z","dependency_job_id":null,"html_url":"https://github.com/jcorrado/slackbot-router","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jcorrado/slackbot-router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcorrado%2Fslackbot-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcorrado%2Fslackbot-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcorrado%2Fslackbot-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcorrado%2Fslackbot-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcorrado","download_url":"https://codeload.github.com/jcorrado/slackbot-router/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcorrado%2Fslackbot-router/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32349459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T17:12:42.749Z","status":"ssl_error","status_checked_at":"2026-04-27T17:12:41.658Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","library","slack"],"created_at":"2024-10-12T21:05:05.271Z","updated_at":"2026-04-27T18:32:17.874Z","avatar_url":"https://github.com/jcorrado.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slackbot-router\n[![Clojars Project](https://img.shields.io/clojars/v/jcorrado/slackbot-router.svg)](https://clojars.org/jcorrado/slackbot-router)\n\nslackbot-router is a small routing library for Slack bots, organizing incoming message tests and reply-generators into tables.  Incoming messages are handled asynchronously.\n\n## Installation\nAdd the following dependency to your `project.clj` file:\n\n\t[jcorrado/slackbot-router \"0.1.1\"]\n\n## Usage\n\n### Bot Setup\nA Slack bot is a web application designed to handle events surfaced by a configured Slack workspace.  Slack offers two patterns: the [Real Time Messaging API](https://api.slack.com/rtm) and the simpler [Events API](https://api.slack.com/events-api); I have only used the latter.\n\nHere is a fragment of a Compojure app that shows the basic idea.  Our message routing rules are in `message-table`, detailed below.\n\nYou will need to configure Ring, via `project.clj` to use your `init` and `handler` fns.\n\n```clojure\n(defproject mybot \"0.1.0\"\n  :dependencies [[org.clojure/clojure \"1.9.0\"]\n                 [jcorrado/slackbot-router \"0.1.1\"]\n                 ;; ...]\n  :ring {:init mybot.handler/init\n         :handler mybot.handler/app})\n```\n\nA simple `mybot.handler` fragment with the basic idea.\n\n```clojure\n(def events-c (chan 100))\n\n(defn slack-event-handler\n  [req]\n  (let [event (:body req)]\n    (try\n      (response (slackbot-router.core/route-event event events-c))\n      (catch java.lang.Exception e\n        (println \"Unknown Slack message type:\" (.getMessage e))\n        ;; We always reply 200 to incoming Slack events\n        (response \"OK\")))))\n\n(defroutes app\n  (POST \"/slack-event\" [body] slack-event-handler))\n\n(defn init\n  []\n  (go-loop []\n    (let [msg (\u003c! events-c)]\n      (if-let [reply (slackbot-router.core/route-message message-table msg)]\n       \t;;\n        ;; The incoming message passed a test in our routinge table\n        ;; and the associated reply generator returned non-nil - do\n        ;; something with that here.\n        ;;\n        ))\n    (recur)))\n```\n\n### Routing Table Design\nA table consists of two-element vectors.  The first element is a test function, to which the message is passed.  If that test returns anything truthy, that returned value is passed to the  second element: the reply-generating function.  A typical design would have that reply, in turn, posted to Slack.  However that's outside of the domain of `slackbot-router`.\n\nHere is a very simple table, with a single route.\n```clojure\n(def basic-table\n  [(fn [msg] (= (:text msg) \"!ping\"))\n   (fn [_] \"!pong\")])\n```\n\nThis simple _test-text/reply-text_ pattern is common enough to warrant a macro, which also supports a regular expression.\n\n```clojure\n(def basic-table\n  [(text-match \"!ping\" \"!pong\")\n   (text-match #\"(?i)^.*deploy(ing)? (to )?prod(uction)?\"\n               \"*leeeroy jeeenkins!!1* :hotdog:\")])\n```\n\nThe return of a successful test is passed to the associated reply generating function.\n```clojure\n(def boromir-table\n  [(text-match \"Who is Boromir?\" \"High Warden of the White Tower\")\n\n   [(fn [msg]\n      (if-let [[_ deed] (re-matches #\"(?i)!boromir\\s+(.+?)\\s*$\" (:text msg))]\n        deed))\n    (fn [deed]\n      (format \"*One does not simply %s*\" deed))]])]\n```\n\nYou may nest tables, breaking your routes apart.\n```clojure\n(def message-table\n  [basic-table\n   boromir-table]))\n```\n\n`slackbot-router` flattens the nested tables and tests, in sequence,\nfrom the top.\n\n\n## License\n\nCopyright © 2018 Jereme Corrado\n\nDistributed under the Eclipse Public License either version 1.0 or (at\nyour option) any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcorrado%2Fslackbot-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcorrado%2Fslackbot-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcorrado%2Fslackbot-router/lists"}