Having Fun with
 Jabber Bots
 Victor Hugo Germano
Why Jabber Bots?
What kinda a crazy am I?
It’s Fun!
http://www.flickr.com/photos/sleepallday/3311794264/
Maybe a glimpse of the future?
                 http://www.flickr.com/photos/dancoulter/21042744/
Dynamic web
Is not enough!
Tired of Ctrl+R and F5




                 http://www.flickr.com/photos/disaster_area/3454110496/
We want websites like this!
But during the game...



      Real time streamming... for sure!
FLASH
Would FLASH be the answer?
No!
At least is what most companies are saying
“Big” Problem
How to create a chat room? Or a chess game?
Because

     Latency Matters
Specially when developing and application
client




server



Traditional Polling
         Often Problematic
?
Any other options?
Extensive Messaging and
   Presence Protocol




   Event-Driven

   XML oriented
Stanzas

  Presence
<presence from="victorhg@im.net/home">
  <status>at #pyconIreland o/</status>
</presence>
Stanzas

Message
<message to="mary@im.net/work"
     from="victorhg@im.net/home"
     type="chat" >
    <body>How u doing?...
Stanzas

  IQ (Info Query)
<iq type="get" id="an_id"
     from="victorhg@im.net/casa"
     to="im.net">
    <query xmlns="...
client




server



         Long Polling
Jabber.org
But XML sucks!
xmppPy is your friend!
xmppPy
conn = xmpp.Client(‘gmail.com’)

conn.connect([server, port])

conn.auth(user, pwd)

conn.send(Message(
       "ema...
First Example
Using GTalkBot



http://github.com/victorhg/botnet/blob/master/botnet/gtalkbot.py
mybot.py
from gtalkbot import GTalkBot, botcommand

class MyBot(GTalkBot):
  def __init__(self):
   super(MyBot,self).__in...
$> python mybot.py
How about a real bot?
Enough with the hello_world
Demo
Add a contact on your GTalk account



pycon.bot@gmail.com
Having fun!
Show me the code!
How can
you use it?

              http://www.flickr.com/photos/flysi/183272970/
Real Time Web?
Powered by XMPP
BOSH
Bidirectional-streams Over Synchronous HTTP
Strophe.js
When XMPP hits the web


    http://code.stanziq.com/strophe/
Strophe.js
// Connecting
var conn = new Strophe.Connection(URL)
conn.connect( jid, password, callback );

// Creating stan...
Who uses XMPP on the web?
References
http://xmpp.org/

http://xmpppy.sourceforge.net/

http://thpinfo.com/2007/python-jabberbot/

http://xmpppy-guid...
Thank you!

   twitter.com/victorhg
google.com/profiles/victorhg


                  Use it! Share it!
                    ...
Having fun with jabber bots
Upcoming SlideShare
Loading in...5
×

Having fun with jabber bots

8,501

Published on

Victor's presentation about xmpp and Jabber bots at Pycon Ireland 2010

Imagine the possibility of creating a real time channel, capable of notifying and interact, using a simple instant messaging application. Integrating such tool on your application could bring real value to you and customers. The main focus of this presentation is to show an easy way to create and use computer bots through the Python language, suggesting useful applications, and bring together some advanced considerations about security and natural language processing.

Learn how to create a bot using jabberBot (5 minute tutorial):
basics
testing
live example
How to make it useful?
Real time notification system
Integration with Yahoo, Exchange APIs
System administration
Getting serious

Alternative libraries
Language Processing

Published in: Technology
4 Comments
5 Likes
Statistics
Notes
No Downloads
Views
Total Views
8,501
On Slideshare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
74
Comments
4
Likes
5
Embeds 0
No embeds

No notes for slide

Having fun with jabber bots

  1. 1. Having Fun with Jabber Bots Victor Hugo Germano
  2. 2. Why Jabber Bots? What kinda a crazy am I?
  3. 3. It’s Fun! http://www.flickr.com/photos/sleepallday/3311794264/
  4. 4. Maybe a glimpse of the future? http://www.flickr.com/photos/dancoulter/21042744/
  5. 5. Dynamic web Is not enough!
  6. 6. Tired of Ctrl+R and F5 http://www.flickr.com/photos/disaster_area/3454110496/
  7. 7. We want websites like this!
  8. 8. But during the game... Real time streamming... for sure!
  9. 9. FLASH
  10. 10. Would FLASH be the answer?
  11. 11. No! At least is what most companies are saying
  12. 12. “Big” Problem How to create a chat room? Or a chess game?
  13. 13. Because Latency Matters Specially when developing and application
  14. 14. client server Traditional Polling Often Problematic
  15. 15. ? Any other options?
  16. 16. Extensive Messaging and Presence Protocol Event-Driven XML oriented
  17. 17. Stanzas Presence <presence from="victorhg@im.net/home">   <status>at #pyconIreland o/</status> </presence>
  18. 18. Stanzas Message <message to="mary@im.net/work"      from="victorhg@im.net/home"      type="chat" >     <body>How u doing? ;) </body> </message>
  19. 19. Stanzas IQ (Info Query) <iq type="get" id="an_id"      from="victorhg@im.net/casa"      to="im.net">     <query xmlns="jabber:iq:roster"/> </iq>
  20. 20. client server Long Polling
  21. 21. Jabber.org
  22. 22. But XML sucks! xmppPy is your friend!
  23. 23. xmppPy conn = xmpp.Client(‘gmail.com’) conn.connect([server, port]) conn.auth(user, pwd) conn.send(Message( "email@gmail.com","hello!")) conn.disconnect()
  24. 24. First Example Using GTalkBot http://github.com/victorhg/botnet/blob/master/botnet/gtalkbot.py
  25. 25. mybot.py from gtalkbot import GTalkBot, botcommand class MyBot(GTalkBot): def __init__(self): super(MyBot,self).__init__('USER_ID','PWD') @botcommand def hello(self, mess, args): return “Hello World!” MyBot().run_client() http://github.com/victorhg/botnet/blob/master/botnet/gtalkbot.py
  26. 26. $> python mybot.py
  27. 27. How about a real bot? Enough with the hello_world
  28. 28. Demo Add a contact on your GTalk account pycon.bot@gmail.com
  29. 29. Having fun! Show me the code!
  30. 30. How can you use it? http://www.flickr.com/photos/flysi/183272970/
  31. 31. Real Time Web? Powered by XMPP
  32. 32. BOSH Bidirectional-streams Over Synchronous HTTP
  33. 33. Strophe.js When XMPP hits the web http://code.stanziq.com/strophe/
  34. 34. Strophe.js // Connecting var conn = new Strophe.Connection(URL) conn.connect( jid, password, callback ); // Creating stanzas var stanza = new Strophe.Builder( “message”, { “to”: “john@jabber.org”, type:”chat” } );
  35. 35. Who uses XMPP on the web?
  36. 36. References http://xmpp.org/ http://xmpppy.sourceforge.net/ http://thpinfo.com/2007/python-jabberbot/ http://xmpppy-guide.berlios.de/ http://code.stanziq.com/strophe/ Real Time Web with XMPP @ InfoQ
  37. 37. Thank you! twitter.com/victorhg google.com/profiles/victorhg Use it! Share it! Remix it!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×