SlideShare a Scribd company logo
a presentation by Marek Kuziel < [email_address] > Djabot – Python Jabber Bot +  Echo  &  HTTP-like JSON API  Bots +  djabotd  – Django daemon command
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
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
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
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
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
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)
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']
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 }
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
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
“ 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'}
“ 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'}
“ 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'}
“ 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'}
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/vshivak/djabot/ Feedback or contributions: Marek Kuziel < [email_address] >
Thank Yo u ! Marek Kuziel, Christchurch, New Zealand, July 2010 This presentation can be found at  http://tracklr.com/tm/presentations/tracklr-djabot.pdf

More Related Content

PPT
MITH Digital Dialogues: Intro to Programming for Humanists (with Ruby)
PPT
Php Training
ODP
Perl Moderno
PDF
7 Common Mistakes in Go (2015)
PPT
Perl Tidy Perl Critic
PPTX
Great APIs
PDF
7 Common mistakes in Go and when to avoid them
PDF
Using Jenkins for Continuous Integration of Perl components OSD2011
MITH Digital Dialogues: Intro to Programming for Humanists (with Ruby)
Php Training
Perl Moderno
7 Common Mistakes in Go (2015)
Perl Tidy Perl Critic
Great APIs
7 Common mistakes in Go and when to avoid them
Using Jenkins for Continuous Integration of Perl components OSD2011

What's hot (20)

PDF
Painless Data Storage with MongoDB & Go
PPT
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
PDF
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
PDF
Boost Maintainability
PDF
Learn php with PSK
ODP
The Basics Of Page Creation
PDF
Low Latency Logging with RabbitMQ (Brno PHP, CZ - 20th Sep 2014)
PDF
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
PDF
Elegant concurrency
PDF
Php tutorial
PPT
Php performance
PDF
Making JavaScript Libraries More Approachable
PDF
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
PPT
Open Source XMPP for Cloud Services
PPTX
Php Extensions for Dummies
PPT
typemap in Perl/XS
PPTX
Php string function
PDF
Introduction to Ruby
PPTX
JavaScript, Beyond the Curly Braces
Painless Data Storage with MongoDB & Go
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Boost Maintainability
Learn php with PSK
The Basics Of Page Creation
Low Latency Logging with RabbitMQ (Brno PHP, CZ - 20th Sep 2014)
Low Latency Logging with RabbitMQ (PHP London - 4th Sep 2014)
Elegant concurrency
Php tutorial
Php performance
Making JavaScript Libraries More Approachable
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
Open Source XMPP for Cloud Services
Php Extensions for Dummies
typemap in Perl/XS
Php string function
Introduction to Ruby
JavaScript, Beyond the Curly Braces
Ad

Similar to Djabot – Python Jabber Bot (20)

PDF
Having fun with jabber bots
PDF
Create a Bot with Delphi and Telegram - ITDevCon 2016
PDF
Icinga Camp New York 2018 - Icinga2bot
PPTX
Breizhcamp: Créer un bot, pas si simple. Faisons le point.
PPTX
Cisco Connect 2018 Indonesia - Build a spark bot
PDF
Build advanced chat bots - Steve Sfartz - Codemotion Amsterdam 2017
PDF
Building advanced Chats Bots and Voice Interactive Assistants - Stève Sfartz ...
PDF
Hello PyBot
PPTX
Rome 2017: Building advanced voice assistants and chat bots
PDF
Writing a slack chatbot mxlos
PDF
Voicecon - Mashups with Tropo.com
PDF
Chat apps v02
PDF
Hey man, can I get a clue?
PDF
Lessons learned from building a commercial bot development platform
PPTX
Chat Bots Presentation 8.9.16
PDF
ATX Bot Talk - Hello PyBot
PDF
chatops-presentation
PDF
Jabber Bot
PPSX
Chatbot
PDF
AmI 2017 - Python intermediate
Having fun with jabber bots
Create a Bot with Delphi and Telegram - ITDevCon 2016
Icinga Camp New York 2018 - Icinga2bot
Breizhcamp: Créer un bot, pas si simple. Faisons le point.
Cisco Connect 2018 Indonesia - Build a spark bot
Build advanced chat bots - Steve Sfartz - Codemotion Amsterdam 2017
Building advanced Chats Bots and Voice Interactive Assistants - Stève Sfartz ...
Hello PyBot
Rome 2017: Building advanced voice assistants and chat bots
Writing a slack chatbot mxlos
Voicecon - Mashups with Tropo.com
Chat apps v02
Hey man, can I get a clue?
Lessons learned from building a commercial bot development platform
Chat Bots Presentation 8.9.16
ATX Bot Talk - Hello PyBot
chatops-presentation
Jabber Bot
Chatbot
AmI 2017 - Python intermediate
Ad

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
Electronic commerce courselecture one. Pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
cuic standard and advanced reporting.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Encapsulation theory and applications.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Cloud computing and distributed systems.
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
MYSQL Presentation for SQL database connectivity
Electronic commerce courselecture one. Pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Programs and apps: productivity, graphics, security and other tools
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Network Security Unit 5.pdf for BCA BBA.
cuic standard and advanced reporting.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Advanced methodologies resolving dimensionality complications for autism neur...
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation_ Review paper, used for researhc scholars
Encapsulation theory and applications.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Cloud computing and distributed systems.
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Review of recent advances in non-invasive hemoglobin estimation
Digital-Transformation-Roadmap-for-Companies.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Understanding_Digital_Forensics_Presentation.pptx

Djabot – Python Jabber Bot

  • 1. a presentation by Marek Kuziel < [email_address] > Djabot – Python Jabber Bot + Echo & HTTP-like JSON API Bots + djabotd – Django daemon command
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. “ 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. “ 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. “ 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. “ 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. Demo HTTP-like JSON API Bot track l r .com Djabot – Python Jabber Bot [email_address] Try it :-)
  • 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. Thank Yo u ! Marek Kuziel, Christchurch, New Zealand, July 2010 This presentation can be found at http://tracklr.com/tm/presentations/tracklr-djabot.pdf