= Blueprint for the Messaging Module = What we need is: * Contacts List * Just uses normal Groups & Persons? * Do we need to extend these at all? (to mark that they're used for a these purposes & have some logic to identify whether all members of a group have emails &/or SMS'able Tel#s. Mark the members when we get delivery failures?) * SMS Router * Routes incoming message according to whether it's using specialist micro-syntax (e.g. submitting an XForm to another controller) * Non-XForms messages get sent to the [wiki:BluePrintTicketing Ticketing] module's Master Message Log * Tagged meesages also get Routed to the appropriate area (Project / Location / Organisation) * SMS alerts (security alerts more common than natural disasters) * Being able to trigger an SMS alert broadcast upon reception of an SMS * Is this just an XForm to a Group? (Can we pre-populate the XForm to do this whenever a certain number is called or just a single word routes here?) * CAP alerts: * http://xml.coverpages.org/OASIS-CAPv11-200510.pdf * Use an XSLT? * http://code.google.com/p/pyedxl/source/browse/trunk/edxl/edxl.py * Subset of EDXL-DE: http://docs.oasis-open.org/emergency/edxl-de/v1.0/EDXL-DE_Spec_v1.0.pdf * http://talksahana.com/2009/03/04/firefox-browser-cap-alerting-plugin-sahana-idea-for-gsoc2009/ * Admin UI for: * Email Settings * SMS Settings * SMS login / data entry / reports * [wiki:BluePrintMessagingModuleJ2ME J2ME client] * Hashtag decoding - e.g. use [http://en.wikipedia.org/wiki/Geohash GeoHashes] ([http://pypi.python.org/pypi/Geohash/ Python lib]) === Core Architecture === Instead of having several "apps" that cross-talk, such as sms, email, tweet, jabber, etc, it would be good to have a central messaging core that has 'connectors'. This would be the equivalent of a star-hub structure. This way, additional 'connectors' could be added or used as needed without refactoring the entire code base, and would allow sending messages from one connector to another, such as sms to email or email to jabber. Need to have per-user inboxes (e.g. to support workflow) === User Interface === The home page should be a common !InBox view which shows all new unread Items (the Ticketing Module). Users/Groups should be able to subscribe to incoming messages of a certain type (Project / Location / Organisation) & have these messages forwarded via SMS / Email / Twitter / etc. Ideally there should be the ability to launch a popup/ticker to notify of new items & a portlet which can be on a user's dashboard when they login. The 'Send Message/Alert' screen should have a small box to enter the Plain-text message which is sent to all recipients (using all available SMS/Email addresses in the Group specified). There should be a 2nd box to create a Rich-text message, with the option of adding attachments. This content just gets sent to those members of the group with an Email address specified. We don't need the option of having Email or SMS groups - all groups are 'Both'. If a user is added to a group we warn about any missing details, but still allow addition (the ref is by person.id so addresses can eb added/changed later anyway). When sending we need to provide warning messages about users for whom details weren't available. === Email === tools.py has mail settings: {{{ mail=MailS3() # These settings should be made configurable as part of the Messaging Module mail.settings.server='mail:25' mail.sender='sahana@sahanapy.org' }}} & a function: {{{ mail.send(to, subject='None', message='None') }}} Can use this to send emails with dynamic data inserted into templates (like HTML pages): * http://groups.google.com/group/web2py/browse_thread/thread/f6c903f9c67cfe2e There is a Cron job to check the contents of the !OutBox & send pending messages. On Success it moves the message to the 'Sent' table: * http://web2py.com/examples/default/cron ==== Rich Text ==== We'd like to be able to send HTML mails for rich-text support (including attachments) This requires the use of smtplib to send MIME-encoded files: * http://groups.google.com/group/web2py/browse_thread/thread/3d8ed693dd2f29bc * https://web2py.com/wiki/default/page/98b7448f-059a-47f7-82da-dce4728aa4dd * Simple app for sending mails from a form (using smtplib): http://web2py.com/appliances/default/show/10 === SMS === Need to be able to support both online gateways (such as Clickatell) & local hardware such as: * a Bluetooth mobile phone * [http://www.mobigater.bg MobiGater] – Takes 1 sim card. Cost approx EUR 70. * [http://www.2n.cz/products/gsm_gateways/voip_gsm_gateway/voiceblue_voip_gsm_gateway.html VoiceBlue Lite] – Takes 4 sim cards and can handle 4 concurrent calls. Cost approx EUR 900. * [http://www.google.com/products?client=safari&rls=en-us&q=multimodem+mtcba-g-f4&oe=UTF-8&um=1&ie=UTF-8&ei=H-6BSpO1DJS-NpC6gaAL&sa=X&oi=product_result_group&ct=title&resnum=4 Multi-Tech MultiModem GPRS MTCBA-G-F4] The SMS Daemon to handle Inbound messages is a separate Python script. It can distinguish between simple messages (added to the !InBox of the Messaging Module) & those which are encoded in Binary XML (the output of XForms from the J2ME client). Implementation details are here: http://wiki.sahanafoundation.org/doku.php/dev:pythonsms Q: Do we use Cron to check !OutBox & signal the daemon to send Pending messages? (as for email) Toolkits we can base on: * SlingshotSMS (PyGSM-based with !CherryPy REST interface): http://code.developmentseed.org/slingshotsms/dashboard * http://developmentseed.org/blog/2009/aug/14/slingshotsms-alpha-code-released-lightweight-sms-gateway-stick * RapidSMS (PyGSM-based): http://rapidsms.org * !PySerial: http://pyserial.wiki.sourceforge.net/pySerial * Gammu: http://www.gammu.org (Python-gammu: http://www.gammu.org/wiki/index.php?title=Gammu:Python-gammu) * Gnokii: http://www.gnokii.org (!PyGnokii: http://mobilehacking.org/index.php/PyGnokii) * Kannel: http://kannel.org (!PyKannel: http://mobilehacking.org/index.php/PyKannel) * SMSTools: http://smstools3.kekekasvi.com Hardware compatibility databases: * http://wiki.gnokii.org/index.php/Config * http://cihar.com/gammu/phonedb/ === Twitter === Adding support for sending out/receiving alerts via Twitter would be nice. This is easy to do within base Web2Py, so this just needs a little UI work to integrate. * http://www.web2py.com/AlterEgo/default/show/224 Hashtags can be parsed using [wiki:pyparsing]. === XMPP === * http://code.google.com/apis/talk/open_communications.html === Alternate implementations === * Agasti design: http://wiki.sahana.lk/doku.php?id=dev:msg_archi * Agasti User Guide http://wiki.sahana.lk/doku.php?id=doc:message:english * [http://instedd.org/geochat GeoChat] * [http://www.frontlinesms.com Frontline SMS] (used by Ushahidi) ---- BluePrints