BluePrint: Social Media
Table of Contents
- Current Implementation
- See Also
Social Media is playing a important role in Disaster and Emergency Management, for such things as:
- Sending warnings and emergency instructions to the public.
- Receiving help requests and incident reports from the public.
- Engaging with the public, encouraging preparedness, providing information.
- Detecting incidents not directly reported.
Best to start by seeing how the current system works.
For ease of getting a large dataset to play with, suggest using Twitter to start off with, although the same system can be used for other message channels, like Email, SMS & RSS.
Install on your own system:
- Install Eden
- Install the TwitterSearch library
- Follow the User Guidelines to get a Twitter OAuth account & use this to search
The current workflow for a user to search Twitter is very cumbersome!
Some ideas for improvements (although feel free to come up with your own!)
- There should be an option (on by default) to have the Search run after save
- The next screen should be the Results:
s3db.configure(create_next = URL(f="twitter_result"))
- There should be some filters above the results:
- There should be a link to see the results on a Map
- this will require modifying the code to have the msg_twitter_result table use self.gis_location_id() Foreign key instead of lat/lon fields
- The S3Map() method is then automatically accessible via /eden/msg/twitter_result/map
- This will use the same filters defined for the list view
- There should be a Report method configured for charts based on pivot tables
- We could create a 'Summary' view which allows the Table, Chart & Map to be separate tabs on a single page, sharing a common set of filters, keeping the settings when moving between the views
- Example: http://demo.lacrmt.sahanafoundation.org/eden/vulnerability/risk/summary
- This is accessible via /eden/msg/twitter_result/summary
- The Chart, Table, Filter, map settings are inherited
- The configuration of which Tabs to display can be seen in the CRMT template
- Can see this locally by switching to the CRMT template:
settings.base.template = "CRMT"in
models/000_config.py& doing a fresh prepopulate
- Run Parsers on the list
- Extract Documents Parser
- Runs on any Message
- Can read attachments?
- Adds all URLs as documents
- msg_message a doc_entity? or use link table
- parses link types to see if there are Images (ideally following links as some links aren't direct to the jpg/png)
- optionally downloads linked images/documents into local store
- Runs on any Message
- Train these parsers
- Extract Documents Parser
- Add tools to the Table view to Geocode, Classify, Forward (to other modules, such as irs_ireport or project_task, &/or via Messaging channels), Whitelist sender, Blacklist sender
- This has overlap with the HIT module approach
- Make it possible to schedule updates to search queries
- Make it easy to add filtered views of query results to the main map
- by creating/editing relevant gis_layer_feature records via a simplified/custom interface
- Display linked Images
- Use the above Extract Documents Parser
- Have a Represent (on a Lazy Virtual Field?) for Table views which displays the Images
- Ideally show thumbnail & hover to display full version in popup?
- Show Images in Map Popups
- Timeline Report?
- Work on KeyGraph visualisation?
- Add Channels for Facebook, YouTube, Flickr, etc
- 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
- Allow users to publish new information to a set of official accounts in an auditable way using their normal Sahana login (sop that they don't need to know the multiple logins for each system & we can track who posted which message to the shared public accounts)
- 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.
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 good use cases here:
The following workflows describe how a message could be responded to. This message may be from Twitter, Facebook(?), SMS or Email. The idea is that Sahana can be used to record the response to all messages.
- A message is received reporting an incident
- The user decides to create an incident based on this message (perhaps it is from a trusted source, perhaps they checked to verify it, perhaps this is their policy)
- That incident is created with a link to this message (for verification)
- If other people see that message, they can see a link to the incident that was created from it.
- A message is received reporting an incident - which has already been recorded in Sahana
- The user links this message to an existing incident
- The message now has a link to this incident. That incident now has a link to this (and all other) related messages.
Request for Volunteers
- A message is received requesting volunteers
- The user creates a request for volunteers (which is linked to/from this message)
Request for Supplies
- A message is received requesting supplies
- The user creates a request for supplies (which is linked to/from this message)
Request for Information
- A message is received asking for information
- A Message is sent in response (either to the person or broadcast) (which is linked to/from the first message)
Some example diagrams are here:
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/modules/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. Module Index Pages)
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.
- 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.
- Create an access token
- Go to eden/msg/twitter_channel , select a channel and enter the details from your Twitter Application.
- Add keywords to be searched:
Go to a page eden/msg/twitter_search. You can add keywords / search queries records under this page.
- Populating database with search results:
After saving the keywords/ queries, click on Search which triggers the search and msg_twitter_search_results table in the database gets populated or if you had selected "Search After Save?" the Search will run automatically after saving
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.
- 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.
- Display twitter icon on map instead of the normal location bubble.
- 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).
- 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.
Walk Through of NYCP Wireframe
This is a quick and not particularly well documented explanation of the wireframes below designed for NYC:Prepared. It has not be integrated into the rest of this wiki page.
- Configure Feeds
- Add available accounts
- Set up filters
- Pick a view
- Preview feed to see what it will look like
- Create feed
- Place feed into layout
- View Feeds
- Select accounts
- Format as Tweet, Post, Request, Events
- Attach media and/or links
- View Feed Items
- Item Editor
This editor can be used to:
- Create New items
- Edit existing items
- Transform items from one format into another format
- In Transform Mode: the existing post in it's current format is placed next to a set of fields of the new format.