Chatbot framework in Clojure.
Currently, jubot supports following adapters and brains:
$ lein new jubot YOUR_JUBOT_PROJECT
$ cd YOUR_JUBOT_PROJECT
$ lein repl
user=> (in "jubot help")
Handler is a function to process user input.
NOTE: This example will response for any addresses because example code does not check :message-for-me?
.
(defn ping-handler
"jubot ping - reply with 'pong'"
[{:keys [text]}]
(if (= "ping" text) "pong"))
:user
: User name:text
: Input string.:to
: Address username.:message-for-me?
: Is inputted message addredded to bot or not.user=> (in "jubot help")
Or you can use handler/regexp
:
(ns foo.bar
(:require
[jubot.handler :as jh]))
(defn ping-handler
[arg]
(jh/regexp arg
#"^ping$" (constantly "pong")))
Developers do not need to specify which handlers are used, because jubot collects handler functions automatically.
/^.*-handler$/
in ns-prefix
will be collected automatically.ns-prefix
is a namespace regular expression. It is defined in YOUR_JUBOT_PROJECT.core
./^.*-test$/
is excluded.Schedule is a function that is called periodically as a cron.
(ns foo.bar
(:require
[jubot.scheduler :as js]))
(def good-morning-schedule
(js/schedules
"0 0 7 * * * *" (fn [] "good morning")
"0 0 21 * * * *" (fn [] "good night")))
scheduler/schedule
or scheduler/schedules
to define one or more schedules.As same as handler section, jubot collects schedule functions automatically.
/^.*-schedule$/
in ns-prefix
will be collected automatically./^.*-test$/
are excluded.Jubot provides some useful funcition to develop chatbot in REPL efficiently.
These functions are defined in dev/user.clj
.
user=> (start) ; start jubot system
user=> (stop) ; stop jubot system
user=> (restart) ; reload sources and restart jubot system
user=> (in "jubot ping")
-a
, --adapter
-b
, --brain
-n
, --name
Procfile
as you wantheroku apps:create
heroku addons:add rediscloud
git push heroku master
Or use following deployment button based on jubot-sample.
heroku config:add SLACK_OUTGOING_TOKEN="aaa"
heroku config:add SLACK_INCOMING_URL="bbb"
heroku config:add AWAKE_URL="Application url on heroku"
Copyright (C) 2015 uochan
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.
Can you improve this documentation? These fine people already did:
liquidz & Masashi IizukaEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close