Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation...

61

Transcript of Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation...

Page 1: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!
Page 2: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Questions?

Please add your questions to http://bit.ly/14uvmG and I will answer them

ASAP

Page 3: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Paul Scott @paulscott56 [email protected] http://www.paulscott.za.net

Page 4: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Based at the University of the Western Cape, Cape Town, South Africa

Page 5: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

But more like based in Africa

Page 6: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

AVOIR - http://avoir.uwc.ac.za/

Page 7: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Drugs and gangsterism are out of control in many communities

Page 8: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Only ~4.5 million internet users

Page 9: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

But, 68% mobile penetration across the board

Page 10: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Upwards of 12.5 million mobile IM users using MXiT and others

Page 11: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

MXiT gets a LOT of bad press as a network for drug dealers to sell their wares on

Page 12: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

But that was all about to change...

Page 13: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

So how does Free Software help?

Page 14: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

In the beginning the world was without form...

Page 15: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!
Page 16: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

A group of community counsellors were using Gtalk to help addicts

Page 17: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

But the interface was inadequate for the volumes of conversations

Page 18: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Users were waiting a long time for a response

Page 19: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

And getting angry...

Page 20: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

In other words, a mess

Page 21: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

So we decided to help...

Page 22: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Chisimba framework + a little coding effort + XMPP library (XMPPHP) = DAS

Page 23: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

DAS = Drug Abuse Support

Page 24: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Great! But......Major scaling issues with the PHP library!

Page 25: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Each conversation created a new socket

Page 26: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Load increased

Page 27: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Until...

Page 28: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!
Page 29: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Time for plan B

Page 30: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Yanked out the PHP for handling the messages

Page 31: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

And slotted in a little Python (http://xmpppy.sf.net/) to get the message

and dump it to the database

Page 32: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

This turned out to be good. (We haven't yet been able to kill it)

Page 33: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

So how does it all work? Very simple!

Page 34: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

User connects to IM service of choice (in most cases MXiT)

Page 35: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

A message is sent to initiate conversation with the counsellor

Page 36: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Counsellor answers and message is automatically queued or manually re-

routed to another counsellor

Page 37: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Messages are answered in a FIFO style, unless they are priority messages

(active suicides occuring whilst on the phone for example)

Page 38: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Counsellors use a web interface in a regular browser to type their chats, so training kept

to a minimum

Page 39: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Mom2.0 project as a result where mothers in the community help out too

Page 40: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Software stack is simple and lightweight so anyone can run it from a laptop and low bandwidth connection even. No need for

expensive hardware

Page 41: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!
Page 42: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Some statistics

Page 43: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!
Page 44: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!
Page 45: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Use cases have now been extended to help out HIV patients

Page 46: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

As well as people seeking career advice and landing a job

Page 47: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

...and a super cheap mobile dictionary for school learners (2000x cheaper than SMS)

Page 48: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

And delivering Wikipedia content (basic, text only pages) to mobile users via Wikipedia

API and XMPP

Page 49: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

More use cases on the way too, also any ideas would be welcome!

Page 50: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

All software is released under GPLv2, so if you think of something cool, let us know!

Page 51: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Some of the code...

Page 52: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

How to write an XMPP bot in a few slides using Chisimba (with explanations)

Page 53: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Chisimba PHPpublic function init() { $this->objSysConfig = $this->getObject

( 'dbsysconfig', 'sysconfig' ); $this->jserver = $this->objSysConfig-

>getValue ( 'jabberserver', 'bot' ); $this->jport = $this->objSysConfig-

>getValue ( 'jabberport', 'bot' ); $this->juser = $this->objSysConfig-

Page 54: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Chisimba PHPpublic function dispatch() { $action = $this->getParam ( 'action' );

switch ($action) { case 'messagehandler' : $this->conn->autoSubscribe (); try { $this->conn->connect (); while ( ! $this->conn-

Page 55: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Chisimba PHPswitch ($event [0]) { case 'message' : switch ($pl ['body']) { default : $this->conn->message($pl['from'],

"I don't understand your request!");

break; case 'hello' :

Page 56: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Chisimba PHP

Add in your configs to register.conf file (as text) and you are good to go!

Page 57: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Chisimba PHP

Execute your messagehandler case as a cron or something to control “uptimes”

Page 58: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Chisimba PHP

Demo “XMPP Bot” code at http://cvs2.uwc.ac.za/trac/chisimba/browse

r/modules/trunk/dumbassbot

Page 59: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

So again, if you have any questions or comments please ask or...

Page 60: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Questions?

add them to http://bit.ly/14uvmG and I will answer them ASAP

Page 61: Questions? - assets.en.oreilly.comassets.en.oreilly.com/1/event/27/Sex, Drugs and XMPP Presentation … · API and XMPP. More use cases on the way too, also any ideas would be welcome!

Photo Credits: http://www.flickr.com/photos/archiemcphee/2978918031/sizes/l/ http://www.flickr.com/photos/veo/1332364512/sizes/l/

Both CC BY-SA licensed