Skip to content
A lightweight clojure wrapper around the smack jabber/XMPP library
Find file
Latest commit 675bc64 @zk Report incorrect username / pass with better exception message. Bump
version to 0.3.1. Fixes #1.


xmpp-clj allows you to write simple jabber bots in idiomatic clojure by providing a lightweight wrapper around the smack library.


[xmpp-clj "0.3.1"]


Create a temporary jabber account for your bot. I've used gmail here, but there are a bunch of free providers

Create a leiningen project and cd into the project directory

lein new mybot
cd ./mybot

Add xmpp-clj to your deps (project.clj):

(defproject mybot "0.1.0"
  :description "FIXME: write"
  :dependencies [[xmpp-clj "0.3.1"]])

Open up src/mybot/core.clj and require the xmpp lib:

(ns mybot.core
  (:require [xmpp-clj :as xmpp]))

Define a handler and start the bot. Handlers accept a single parameter -- the message map -- and should return a string with a message back to the sender. Return nil to omit a response. Here's a very simple example:

;; This bot always responds with the message 'Ermahgerd!!!'

(xmpp/start-bot :username ""
                :password "clojurebot12345"
                :host ""
                :domain ""
                :handler (fn [m] "Ermahgerd!!!")

Next, fire up your chat client, add your new bot buddy, and send him / her a message. The response should look someting like this:

me: hello chatbot

chatbot: Ermahgerd!!!

;; Stop the bot when you're done:


;; You can use a name to start / stop multiple bots in the same
;; process:

(xmpp/start-bot :name :bot1
                :username ...)

(xmpp/start-bot :name :bot2
                :username ...)

(xmpp/stop-bot :bot1)
(xmpp/stop-bot :bot2)

;; And names can be any value / object:

(xmpp/start-bot :name 0
                :username ...)

(xmpp/start-bot :name 1
                :username ...)

See the src/xmpp_clj/examples folder for additional examples. If you'd like to manually manage connections, see the namespace.


Open up an issue


Eclipse Public License v1.0

Something went wrong with that request. Please try again.