= !BluePrint: Social Media = [[TOC]] == Introduction == Social Media is playing a important role in Disaster and Emergency Management. == Description == [[BR]] == Requirements == * Create searches/filters of various social media feeds * Simple hashtag search * Machine learning algorithms(?) * Ability to display these feeds on [BluePrint/UserInterface/Dashboard Dashboards] * Display on the map * Trends over time * Ability to track actions (tasks?) take in response to Social Media messages * Measure Social Media Engagement * Number of followers (+ trends over time) * Number of Tweets (+ trends over time) * Number of re-tweets / likes (+ trends over time) * Share information from Sahana Eden on Social Media * A user sharing it on their accounts * Allow Sahana Eden to publish new information automatically to it's own account EOC staff are overwhelmed - in the first phases of an emergency they can only act on big picture information (e.g. clusters of incidents) rather than individual incidents. Displaying a screenful of photos allows one to quickly get a good amount of information. == Use-Cases == As an Emergency Manager, in order to support the decision making for the type of the resources allocated, the type of response (containment, evacuation etc.) and the scale of response, the information needed woud possibly include: - The type of incident (Fire, earthquake, chemical gas release, civil disturbance etc.) - Secondary hazards - Any information that would be helpful to prioritise the life saving activities (between incidents and within incident) - Any logistics support that might be needed (crane to clear the path, mobile radio repeater to ensure flawless communication etc.) - Secondary (non-life saving) response (food, shelter, communication etc.) - Local response resources (human, tools, vehicles, facilities etc.) available that might be helpful Some possible workflow diagrams may look like: [[Image(https://docs.google.com/drawings/pub?id=1tlQVX5KhXx9qRYerVXQtdbbw_JOWS4z4ryJUu_DPOaI&w=1174&h=789)]] https://docs.google.com/drawings/d/1tlQVX5KhXx9qRYerVXQtdbbw_JOWS4z4ryJUu_DPOaI/edit [[Image(https://docs.google.com/drawings/pub?id=1w_lCzWI9GzE0mqLOdCr3fHUvnTYyKEvuFDbGsc8kYk4&w=1011&h=744)]] https://docs.google.com/drawings/d/1w_lCzWI9GzE0mqLOdCr3fHUvnTYyKEvuFDbGsc8kYk4/edit [[Image(https://docs.google.com/drawings/pub?id=1P2uO0_kmfk324z53gPS1ypHgh3eCP2jtQway_LcVONk&w=1036&h=795)]] https://docs.google.com/drawings/d/1P2uO0_kmfk324z53gPS1ypHgh3eCP2jtQway_LcVONk/edit [[Image(https://docs.google.com/drawings/pub?id=1Lv4w-GVHmUg2TrGV994v1_lhyBvcfZ1tV8hsm2_Ptfg&w=1174&h=789)]] https://docs.google.com/drawings/d/1Lv4w-GVHmUg2TrGV994v1_lhyBvcfZ1tV8hsm2_Ptfg/edit == Projects == There is a huge scope for for Social Media Integration in Sahana Eden some of which have been listed here. These are some more specific projects you may be able to engage with === Social Media Feeds === Enhance the feeds which are displayed on the homepage https://github.com/flavour/eden/blob/master/controllers/default.py#L283 which are controlled with these settings https://github.com/flavour/eden/blob/master/private/templates/000_config.py#L9. * Improve the styling of these feeds * Allow users to create their own dashboard with customized feeds * Re-factor the code so that it is easy to insert feeds on other pages (eg. [wiki:BluePrint/UserInterface#ModuleIndexPages Module Index Pages]) [=#mapfeeds] === Map Feeds === This project allows the user to add layers of Geo-tagged data from Twitter onto the Map. It searches for tweets with specific keywords (that can be configured by user on Sahana web page). It then plots the location of these tweets on the Map. ==== Searching Tweets ==== * Configuring twitter account: Sign into https://dev.twitter.com and create an app. (Select an application Type: Client). Put the Callback URL as blank and create your own Twitter application. After creating an app on twitter account, you will be able to see a tab called OAuth tool. Open eden/models/000_config.py file. Under Twitter Settings, add consumer_key and consumer_secret obtained from the twitter app's OAuth tool. Edit the following lines in 000_config.py {{{settings.msg.twitter_oauth_consumer_key = ""}}}[[BR]] {{{settings.msg.twiiter_oauth_consumer_secret = ""}}} * Add keywords to be searched: Go to a page eden/msg/twitter_search. You can add keywords / search queries records under this page. It will ask you for a PIN to enter before saving the keywords/queries. The pin is obtained from Twitter app that was created. * Populating database with search results: After saving the keywords/ queries, click on Results which triggers the search and msg_twitter_search_results table in the database gets populated. ==== Processing Tweets ==== After fetching the twitter feeds, the Geo-tagged tweets are processed. They are parsed to fetch user information, tweet data and location information in terms of latitude and longitude. All this information then goes into the msg_twitter_search_results table. ==== Plotting tweets on Map ==== To display tweets on map, a new layer named "Twitter" is added under the overlays section on the map page. When a user selects this option, the location ids from the msg_twitter_search_results are fetched and a marker is displayed on those locations. Clicking on the marker image displays additional tweet information such as content, time and user info. ==== Future Scope ==== 1. Major limitation is that the twitter search keyword is hard coded.We need to make the code access the msg_twitter_search table and use the keywords stored by the user through the GUI to search and display twitter feeds on the GIS map. 2. Display twitter icon on map instead of the normal location bubble. 3. Work on the pop-up contents. Ideally this would include any photo or video linked in the message (or a URL if it's to a page of text). Actually doing the part within the tweet parsing of following embedded URLs to identify if they're Media would be really useful addition to the parser (there is a commented-out stub). 4. Create a cron job, to search tweets periodically and not only at user's request. === Publishing data to Social Media Account === Allow Sahana Eden to be configured to have a Facebook or Twitter account it updates to. Look at the msg_search_subscription_notifications function (https://github.com/flavour/eden/blob/master/modules/s3db/msg.py#L818) which is used to send emails to users for Saved Searches - ideally this could also be used to save search criteria, and then when new records in that search are updated - a FB or Twitter update for the system is updated. == Design == Some design considerations and requirements for integrating Social Media into emergency operations. [http://www.slideshare.net/conniewhite/sahana-eden-gsoc-social-media-integration] == Implementation == == References == * [http://www.slideshare.net/conniewhite/designing-a Designing a Social Media Module for Emergency Management in Sahana Eden] * [http://www.slideshare.net/socialandcivic/social-media-in-emergencies-communications-guidelines Social Media in emergencies communications guidelines] * http://www.emergencymgmt.com/emergency-blogs/disasters20/Twitter-Trends-Disaster-Response-090412.html ---- BluePrints BluePrints