a presentation by Marek Kuziel < [email_address] > Djabot – Python Jabber Bot +  Echo  &  HTTP-like JSON API  Bots +  djab...
track l r .com Marek Kuziel < [email_address] > #my #experience #in #hashtags #... #opensource #php #python #java #javascr...
Jabber/XMPP track l r .com Djabot – Python Jabber Bot Good security – TLS support Decentralized – You can run your own Jab...
What Is a Jabber Bot? track l r .com Djabot – Python Jabber Bot An unmanned Jabber/XMPP client Runs as a program on a comp...
Introducing Djabot track l r .com Djabot – Python Jabber Bot Python Jabber client – TLS support, extensible (bots, auth) E...
Djabot – More Information track l r .com Djabot – Python Jabber Bot Requires: PyXMPP, M2Crypto, libxml2-python, dnspython ...
Djabot – Example Code track l r .com Djabot – Python Jabber Bot #/usr/bin/env python from pyxmpp.all import JID from djabo...
Djabot – Example Echo Bot Code track l r .com Djabot – Python Jabber Bot from djabot.bots.base import Djabot as Base class...
Djabot commands –  inputs track l r .com Djabot – Python Jabber Bot djabot processes received Jabber msg & passes the foll...
Jabber/XMPP HTTP-like JSON API track l r .com Djabot – Python Jabber Bot What? request/response JSON API over Jabber/XMPP ...
Core properties of the API protocol track l r .com Djabot – Python Jabber Bot HTTP  status   code  and  message  property ...
“ GTalk – djabot” example chat about  GET track l r .com Djabot – Python Jabber Bot me:   {&quot;action&quot;: &quot;GET&q...
“ GTalk – djabot” example chat about  PUT track l r .com Djabot – Python Jabber Bot me:   {&quot;action&quot;: &quot;PUT&q...
“ GTalk – djabot” example chat about  POST track l r .com Djabot – Python Jabber Bot me:   {&quot;action&quot;: &quot;POST...
“ GTalk – djabot” example chat about  DELETE track l r .com Djabot – Python Jabber Bot me:   {&quot;action&quot;: &quot;DE...
Demo HTTP-like JSON API Bot track l r .com Djabot – Python Jabber Bot [email_address] Try it :-)
Djabot – Source Code track l r .com Djabot – Python Jabber Bot Released 2010/07/17 under BSD License http://bitbucket.org/...
Thank Yo u ! Marek Kuziel, Christchurch, New Zealand, July 2010 This presentation can be found at  http://tracklr.com/tm/p...
Upcoming SlideShare
Loading in …5
×

Djabot – Python Jabber Bot

3,308 views

Published on

Djabot – Python Jabber Bot + Echo & HTTP-like JSON API Bots + djabotd – Django daemon command

Published in: Technology
4 Comments
3 Likes
Statistics
Notes
  • Heh, I *do* hope you find this presentation when looking for XMPP services! :)

    I did the presentation at ChCh NZPUG meetup, but I am not sure whether there is any link between the slides and NZPUG. Most likely not.

    The things you like about it are exactly the ones I had on mind when I created it.

    Btw. there are few other things such as:

    - no need for OAuth, because the problem OAuth is trying to solve does not apply here
    - simpler to implement client anywhere (a XMPP lib can be found for any language and then it's only JSON to process. simple as)
    - simpler to develop APIs and debug them because you can simply chat with your API :)

    Btw. I've got a bot laying around that talks to Arduino. so I can chat to physical devices via GTalk or any Jabber client.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Yes. And funnily enough I stumbled upon it while looking for XMPP services, not through NZPUG.

    What I particularly like about this approach are these two facts:

    1. Event driven nature, no polling required (real-time and demand driven)
    2. Easy point-to-point communicatoin, no point-to-server-to-point schemes required, or server implementations on an end point.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Glad to hear you like the idea! IMO it is easier than usual HTTP based RESTful JSON APIs. Allows to implement machine/machine real-time chatting :)
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • I particularly like the idea of a RESTful JSON API over XMPP rather than HTML. I'll have to try that ... :)
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
3,308
On SlideShare
0
From Embeds
0
Number of Embeds
115
Actions
Shares
0
Downloads
0
Comments
4
Likes
3
Embeds 0
No embeds

No notes for slide

Djabot – Python Jabber Bot

  1. 1. a presentation by Marek Kuziel < [email_address] > Djabot – Python Jabber Bot + Echo & HTTP-like JSON API Bots + djabotd – Django daemon command
  2. 2. track l r .com Marek Kuziel < [email_address] > #my #experience #in #hashtags #... #opensource #php #python #java #javascript #html #xhtml #docbook #xslt #css #linux #nginx #postgresql #mysql #memcache #apache #subversion #mercurial #phing #pear #deployment #scaling #automation #tomcat #javaws #arduino #8051 #Z80 #assembly #GWT #drupal #django #wsgi #jabber #xmpp #thegimp #openid #oauth #ecommerce #zencart #titanium #mobile #tracklr #tracklr2mindmap #djauthy #djabot Djabot – Python Jabber Bot
  3. 3. Jabber/XMPP track l r .com Djabot – Python Jabber Bot Good security – TLS support Decentralized – You can run your own Jabber/XMPP server Open – Standards, community, code
  4. 4. What Is a Jabber Bot? track l r .com Djabot – Python Jabber Bot An unmanned Jabber/XMPP client Runs as a program on a computer (ie. as a Linux daemon) Processes incoming messages from other clients
  5. 5. Introducing Djabot track l r .com Djabot – Python Jabber Bot Python Jabber client – TLS support, extensible (bots, auth) Example bots: echo , HTTP-like JSON API djabotd – Django command that implements Djabot and allows you to run bots for your Django based app as a daemon
  6. 6. Djabot – More Information track l r .com Djabot – Python Jabber Bot Requires: PyXMPP, M2Crypto, libxml2-python, dnspython Allows you to provide your own auth callback function to protect your bots Allows you to write as many bots as you like and configure your instance to use them
  7. 7. Djabot – Example Code track l r .com Djabot – Python Jabber Bot #/usr/bin/env python from pyxmpp.all import JID from djabot.djabot import Client if __name__ == '__main__: def auth_check(requestSenderJID): return True # reply to any sender / do not check sender's JID at all BOTS = ['djabot.bots.echo'] c=Client(JID('USERNAME'), 'PASSWORD', 'tls_noverify', BOTS, auth_check) c.connect() c.loop(1)
  8. 8. Djabot – Example Echo Bot Code track l r .com Djabot – Python Jabber Bot from djabot.bots.base import Djabot as Base class Djabot(Base): NAME = 'djabot-echo-bot' def command_echo(self, inputs): return inputs['body'] def status(self, inputs): return 'echoed back: echo %s' % inputs['body']
  9. 9. Djabot commands – inputs track l r .com Djabot – Python Jabber Bot djabot processes received Jabber msg & passes the following dictionary as inputs parameter to any command that you define: inputs = { 'subject': subject, # subject of received msg 'body': body, # body of received msg 'body_json': None, # JSON object ( if possible to load body as JSON) 'jid': sender, # JID of sender }
  10. 10. Jabber/XMPP HTTP-like JSON API track l r .com Djabot – Python Jabber Bot What? request/response JSON API over Jabber/XMPP that mimics HTTP (status code; PUT|POST|GET|DELETE verbs) Why? I prefer “chatting” with my app instead of RESTful HTTP based approach Seriously. Why? Faster & easier implementation of APIs
  11. 11. Core properties of the API protocol track l r .com Djabot – Python Jabber Bot HTTP status code and message property in response transaction property to uniquely identify sent/received messages api property for version namespace of given action property in request
  12. 12. “ GTalk – djabot” example chat about GET track l r .com Djabot – Python Jabber Bot me: {&quot;action&quot;: &quot;GET&quot;, &quot;api&quot;: &quot;1.0&quot;, &quot;data&quot;: {&quot;id&quot;: &quot;123&quot;}, &quot;object&quot;: &quot;OBJECT&quot;, &quot;transaction&quot;: &quot;1234567890&quot;} djabot: {'message': u'GET OBJECT ID 123 OK', 'code': '200', 'data': '{&quot;id&quot;: &quot;123&quot;, &quot;example_data&quot;: &quot;EXAMPLE&quot;}', 'transaction': u'1234567890'}
  13. 13. “ GTalk – djabot” example chat about PUT track l r .com Djabot – Python Jabber Bot me: {&quot;action&quot;: &quot;PUT&quot;, &quot;api&quot;: &quot;1.0&quot;, &quot;data&quot;: {&quot;id&quot;: 123}, &quot;object&quot;: &quot;OBJECT&quot;, &quot;transaction&quot;: &quot;1234567890&quot;} djabot: {'message': u'PUT OBJECT ID 123 OK', 'code': '200', 'transaction': u'1234567890'}
  14. 14. “ GTalk – djabot” example chat about POST track l r .com Djabot – Python Jabber Bot me: {&quot;action&quot;: &quot;POST&quot;, &quot;api&quot;: &quot;1.0&quot;, &quot;data&quot;: {&quot;id&quot;: 123}, &quot;object&quot;: &quot;OBJECT&quot;, &quot;transaction&quot;: &quot;1234567890&quot;} djabot: {'message': u'POST OBJECT ID 123 OK', 'code': '200', 'transaction': u'1234567890'}
  15. 15. “ GTalk – djabot” example chat about DELETE track l r .com Djabot – Python Jabber Bot me: {&quot;action&quot;: &quot;DELETE&quot;, &quot;api&quot;: &quot;1.0&quot;, &quot;data&quot;: {&quot;id&quot;: 123}, &quot;object&quot;: &quot;OBJECT&quot;, &quot;transaction&quot;: &quot;1234567890&quot;} djabot: {'message': u'DELETE OBJECT ID 123 OK', 'code': '200', 'transaction': u'1234567890'}
  16. 16. Demo HTTP-like JSON API Bot track l r .com Djabot – Python Jabber Bot [email_address] Try it :-)
  17. 17. Djabot – Source Code track l r .com Djabot – Python Jabber Bot Released 2010/07/17 under BSD License http://bitbucket.org/vshivak/djabot/ Feedback or contributions: Marek Kuziel < [email_address] >
  18. 18. Thank Yo u ! Marek Kuziel, Christchurch, New Zealand, July 2010 This presentation can be found at http://tracklr.com/tm/presentations/tracklr-djabot.pdf

×