== Inbound Message Parsing == [[TOC]] == Introduction == This is a project proposal for GSoC 2012. We need to parse inbound messages, with an initial focus being [wiki:BluePrint/Messaging#SMS SMS]. We can test this with [http://www.clickatell.com/pricing/us_small_business.php Clickatell] or a local phone (the Clickatell Inbound SMS fucntionality needs to be developed, which could be in-scope for this project). == Where should the code live? == Currently message parsing is done in the core code: [https://github.com/flavour/eden/blob/master/modules/s3/s3msg.py#L192 modules/s3/s3msg.py] We want to be able to make this a deployment-specific set of options. We are still working on developing our [https://groups.google.com/forum/?fromgroups#!topic/sahana-eden/Vy8xT4bA_pA Profile Layer] for having deployment-specific files separated from core code, so we can start by just making this a deployment-template like [https://github.com/flavour/eden/blob/master/deployment-templates/models/000_config.py 000_config.py] copying the file to {{{modules/s3/s3parsing.py}}} for easy import into S3MSG. == How does the code get run? == The Inbound Message receiving tasks should be run via the Scheduler: * https://github.com/flavour/eden/blob/master/models/zzz_1st_run.py#L18 Before exiting those threads, it should trigger a new Schduled task (once, now) to do the parsing. All Parser Workflows should be defined in tasks.py. The Configuration links these Tasks to Inbound Sources, along with any other args, in a new msg_workflow table. - so this can be linking 2 FKs in the scheduler_task table Tropo, however, is different, since that receives inbound connections to it's controller. In order to make this consistent a schduled task can be created but set to never run on schedule & have that run from the controller (or, even better, have this run the same code that the schduled task runs but inline...since this will be pretty much a no-op other than triggering the parser, so won't hold the Tropo connection up & avoids having to spawn a new thread). == Parsing == We want to be able to process [wiki:BluePrint/Messaging/OpenGeoSMS OpenGeoSMS] If we need to have complex parsing, then we can make use of [wiki:pyparsing pyparsing] [wiki:BluePrint/Messaging#Parser Parser] == Routing == We want to be able to direct the message to the appropriate module to handle the data. This could be done either by launching a real [wiki:S3XRC/RESTfulAPI/URLFormat REST request] or else simulating one via the API. {{{ resource = s3mgr.define_resource("module", "resourcename") }}} ''tbc'' == Use Cases == This will be used by at least [wiki:BluePrintCERT CERT] & [wiki:Deployments/TzuChi Tzu Chi]. They wish to process responses to deployment notifications where the recipients send back at least 'Accepted' / 'Reject'. Additional information that it would be useful to capture are: * Current Location * ETA to deployment location * !Questions/Comments (free text) == GSoC Project == * wiki:GSOC2012/MessageParsing