Home

Awesome

jubot

Circle CI Dependency Status

API Docs

jubot Chatbot framework in Clojure.

Currently, jubot supports following adapters and brains:

Why jubot?

Getting Started

$ lein new jubot YOUR_JUBOT_PROJECT
$ cd YOUR_JUBOT_PROJECT
$ lein repl
user=> (in "jubot help")

Handlers

Handler is a function to process user input.

Ping pong example:

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=> (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")))

Which handlers are collected automatically?

Developers do not need to specify which handlers are used, because jubot collects handler functions automatically.

Schedules

Schedule is a function that is called periodically as a cron.

Good morning/night example:

(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")))

Which schedules are collected automatically?

As same as handler section, jubot collects schedule functions automatically.

Development in REPL

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")

Command line arguments

Adapter name: -a, --adapter

Brain name: -b, --brain

Chatbot name: -n, --name

Deploy to Heroku

  1. Edit Procfile as you want
  2. Create and deploy (the following sample uses Redis as a brain)
heroku apps:create
heroku addons:add rediscloud
git push heroku master

Or use following deployment button based on jubot-sample.

Deploy

Slack setting

heroku config:add SLACK_OUTGOING_TOKEN="aaa"
heroku config:add SLACK_INCOMING_URL="bbb"

Advanced setting for heroku

heroku config:add AWAKE_URL="Application url on heroku"

License

Copyright (C) 2015 uochan

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.